{"version":3,"sources":["../node_modules/clsx/dist/clsx.m.js","../../src/utils/propValidator.ts","../../src/utils/constant.ts","../../src/utils/cssTransition.tsx","../../src/utils/collapseToast.ts","../../src/core/eventManager.ts","../../src/hooks/useKeeper.ts","../../src/hooks/toastContainerReducer.ts","../../src/hooks/useToastContainer.ts","../../src/hooks/useToast.ts","../../src/components/CloseButton.tsx","../../src/components/ProgressBar.tsx","../../src/components/Icons.tsx","../../src/components/Toast.tsx","../../src/components/Transitions.tsx","../../src/components/ToastContainer.tsx","../../src/core/toast.tsx"],"names":["toVal","mix","k","y","str","Array","isArray","length","tmp","x","i","arguments","isNum","v","isNaN","isBool","isStr","isFn","parseClassName","isToastIdValid","toastId","canUseDom","window","canBeRendered","content","isValidElement","POSITION","TOP_LEFT","TOP_RIGHT","TOP_CENTER","BOTTOM_LEFT","BOTTOM_RIGHT","BOTTOM_CENTER","TYPE","INFO","SUCCESS","WARNING","ERROR","DEFAULT","cssTransition","enter","exit","appendPosition","collapse","collapseDuration","children","position","preventExitTransition","done","nodeRef","isIn","enterClassName","exitClassName","baseClassName","useRef","animationStep","e","node","duration","scrollHeight","style","requestAnimationFrame","setTimeout","collapseToast","useLayoutEffect","onEnter","useEffect","onExited","onExit","React","eventManager","list","emitQueue","on","this","set","event","off","cb","get","cancelEmit","timers","emit","args","timer","callback","useKeeper","arg","refresh","ref","reducer","state","action","id","useToastContainer","props","forceUpdate","useReducer","toast","dispatch","containerRef","toastCount","queue","collection","instance","toastKey","displayedToast","containerId","isToastActive","getToast","type","appendToast","delay","staleId","options","updateId","isNotValid","data","closeToast","removeToast","isNotAnUpdate","toastAutoClose","containerAutoClose","toastProps","isLoading","theme","icon","key","closeButton","rtl","transition","className","bodyClassName","bodyStyle","onClick","pauseOnHover","pauseOnFocusLoss","draggable","draggablePercent","draggableDirection","closeOnClick","progressClassName","progressStyle","autoClose","hideProgressBar","progress","role","deleteToast","queueLen","freeSlot","dequeueToast","toDequeue","removeFromCollection","toastContent","cloneElement","getToastToRender","toastToRender","toastList","Object","p","getX","getY","useToast","useState","isRunning","setIsRunning","setPreventExitTransition","toastRef","drag","start","delta","removalDistance","canCloseOnClick","canDrag","boundingRect","syncProps","top","bottom","left","right","pauseToast","playToast","Math","document","bindFocusEvents","eventHandlers","onMouseDown","onTouchStart","onMouseUp","onTouchEnd","onDragTransitionEnd","CloseButton","ariaLabel","viewBox","fillRule","d","ProgressBar","hide","userStyle","controlledProgress","animationDuration","animationPlayState","opacity","defaultClassName","cx","classNames","animationEvent","Svg","rest","width","height","fill","Icons","info","warning","success","error","spinner","Toast","Transition","cssClasses","isProgressControlled","maybeIcon","iconProps","Icon","renderCloseButton","Bounce","ToastContainer","containerStyle","pointerEvents","getClassName","newestOnTop","containers","lazy","generateToastId","getToastId","dispatchToast","containerDomNode","render","mergeOptions","createToastByType","pending","resetParams","resolver","params","input","result","promise","err","container","oldOptions","oldContent","nextOptions","config","containerConfig","latestInstance","containerInstance","item"],"mappings":"6NAAA,SAASA,EAAMC,GACd,IAAIC,EAAGC,EAAGC,EAAI,GAEd,GAAmB,kBAARH,GAAmC,kBAARA,EACrCG,GAAOH,OACD,GAAmB,kBAARA,EACjB,GAAII,MAAMC,QAAQL,GACjB,IAAKC,EAAE,EAAGA,EAAID,EAAIM,OAAQL,IACrBD,EAAIC,KACHC,EAAIH,EAAMC,EAAIC,OACjBE,IAAQA,GAAO,KACfA,GAAOD,QAKV,IAAKD,KAAKD,EACLA,EAAIC,KACPE,IAAQA,GAAO,KACfA,GAAOF,GAMX,OAAOE,EAGO,iBAEd,IADA,IAASI,EAAKC,EAAVC,EAAE,EAAWN,EAAI,GACdM,EAAIC,UAAUJ,SAChBC,EAAMG,UAAUD,QACfD,EAAIT,EAAMQ,MACbJ,IAAQA,GAAO,KACfA,GAAOK,GAIV,OAAOL,G,uWClCQQ,EAAMC,GACpB,MAAoB,kBAANA,IAAmBC,MAAjC,G,SAGcC,EAAOF,GACrB,yBAAcA,E,SAGAG,EAAMH,GACpB,wBAAc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iCuF,gBACzB8I,EAAYjB,MAAe7H,GAAjC,GACA,SAEO8I,WAAP,GAFuB,KA6KP5I,CAASzF,EAAvB,GACA,KAAW,CACT,IAAesO,EAAoCxJ,EAAnD,MAAoCyJ,EAAezJ,EAAnD,QAEM0J,EAAc,EAAH,QAGfxO,QAAS8F,WAHM,EAIfC,SAAUuH,MAGRkB,YAAJ,IAAqCA,aAErC,IAAMpO,EAAUoO,UAAhB,SACOA,EAAP,OAEAhB,EAAcpN,EAAdoN,MAjBJ9K,IAyBFoC,OAAa,YACXA,WAAiB,CACf+C,SAAU,KAQd/C,WAAiB,YAIf,OAHIjF,EAAJ,IACEqD,UAEK,WACLrD,MAAkBqD,EAAA,MAAlBrD,KAOJiF,YAAkB,iBAAC2J,UAA8B,IAC/CpB,KACAqB,KAGF5J,aACAA,SAMA5B,QACsB,YAClByL,EAAiBC,eAAjBD,EACAvB,WAEAlI,WAAc,SAAA2J,GACZ3L,SAA8B2L,EAA9B3L,QAA4C2L,EAA5C3L,YAGFgC,QATJhC,MAWyB,YACrBkK,EAAU,OAAQwB,eAAlBxB,GAEA,IAAIA,QACFlK,uBAMEjD,GAAJ,GACEkK","file":"static/js/12.4a9b2ab5.chunk.js","sourcesContent":["function toVal(mix) {\n\tvar k, y, str='';\n\n\tif (typeof mix === 'string' || typeof mix === 'number') {\n\t\tstr += mix;\n\t} else if (typeof mix === 'object') {\n\t\tif (Array.isArray(mix)) {\n\t\t\tfor (k=0; k < mix.length; k++) {\n\t\t\t\tif (mix[k]) {\n\t\t\t\t\tif (y = toVal(mix[k])) {\n\t\t\t\t\t\tstr && (str += ' ');\n\t\t\t\t\t\tstr += y;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor (k in mix) {\n\t\t\t\tif (mix[k]) {\n\t\t\t\t\tstr && (str += ' ');\n\t\t\t\t\tstr += k;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn str;\n}\n\nexport default function () {\n\tvar i=0, tmp, x, str='';\n\twhile (i < arguments.length) {\n\t\tif (tmp = arguments[i++]) {\n\t\t\tif (x = toVal(tmp)) {\n\t\t\t\tstr && (str += ' ');\n\t\t\t\tstr += x\n\t\t\t}\n\t\t}\n\t}\n\treturn str;\n}\n","import { isValidElement } from 'react';\n\nimport { Id } from '../types';\n\nexport function isNum(v: any): v is Number {\n return typeof v === 'number' && !isNaN(v);\n}\n\nexport function isBool(v: any): v is Boolean {\n return typeof v === 'boolean';\n}\n\nexport function isStr(v: any): v is String {\n return typeof v === 'string';\n}\n\nexport function isFn(v: any): v is Function {\n return typeof v === 'function';\n}\n\nexport function parseClassName(v: any) {\n return isStr(v) || isFn(v) ? v : null;\n}\n\nexport function isToastIdValid(toastId?: Id) {\n return toastId === 0 || toastId;\n}\n\nexport function getAutoCloseDelay(\n toastAutoClose?: false | number,\n containerAutoClose?: false | number\n) {\n return toastAutoClose === false ||\n (isNum(toastAutoClose) && toastAutoClose > 0)\n ? toastAutoClose\n : containerAutoClose;\n}\n\nexport const canUseDom = !!(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n);\n\nexport function canBeRendered(content: T): boolean {\n return (\n isValidElement(content) || isStr(content) || isFn(content) || isNum(content)\n );\n}\n","import { ToastPosition, TypeOptions } from '../types';\n\ntype KeyOfPosition =\n | 'TOP_LEFT'\n | 'TOP_RIGHT'\n | 'TOP_CENTER'\n | 'BOTTOM_LEFT'\n | 'BOTTOM_RIGHT'\n | 'BOTTOM_CENTER';\n\ntype KeyOfType = 'INFO' | 'SUCCESS' | 'WARNING' | 'ERROR' | 'DEFAULT';\n\nexport const POSITION: { [key in KeyOfPosition]: ToastPosition } = {\n TOP_LEFT: 'top-left',\n TOP_RIGHT: 'top-right',\n TOP_CENTER: 'top-center',\n BOTTOM_LEFT: 'bottom-left',\n BOTTOM_RIGHT: 'bottom-right',\n BOTTOM_CENTER: 'bottom-center'\n};\n\nexport const TYPE: { [key in KeyOfType]: TypeOptions } = {\n INFO: 'info',\n SUCCESS: 'success',\n WARNING: 'warning',\n ERROR: 'error',\n DEFAULT: 'default'\n};\n\nexport const enum Default {\n COLLAPSE_DURATION = 300,\n DEBOUNCE_DURATION = 50,\n CSS_NAMESPACE = 'Toastify',\n DRAGGABLE_PERCENT = 80\n}\n\nexport const enum Direction {\n X = 'x',\n Y = 'y'\n}\n","import React, { useEffect, useLayoutEffect, useRef } from 'react';\nimport { ToastTransitionProps } from '../types';\n\nimport { collapseToast } from './collapseToast';\nimport { Default } from './constant';\n\nexport interface CSSTransitionProps {\n /**\n * Css class to apply when toast enter\n */\n enter: string;\n\n /**\n * Css class to apply when toast leave\n */\n exit: string;\n\n /**\n * Append current toast position to the classname.\n * If multiple classes are provided, only the last one will get the position\n * For instance `myclass--top-center`...\n * `Default: false`\n */\n appendPosition?: boolean;\n\n /**\n * Collapse toast smoothly when exit animation end\n * `Default: true`\n */\n collapse?: boolean;\n\n /**\n * Collapse transition duration\n * `Default: 300`\n */\n collapseDuration?: number;\n}\n\nconst enum AnimationStep {\n Enter,\n Exit\n}\n\n/**\n * Css animation that just work.\n * You could use animate.css for instance\n *\n *\n * ```\n * cssTransition({\n * enter: \"animate__animated animate__bounceIn\",\n * exit: \"animate__animated animate__bounceOut\"\n * })\n * ```\n *\n */\nexport function cssTransition({\n enter,\n exit,\n appendPosition = false,\n collapse = true,\n collapseDuration = Default.COLLAPSE_DURATION\n}: CSSTransitionProps) {\n return function ToastTransition({\n children,\n position,\n preventExitTransition,\n done,\n nodeRef,\n isIn\n }: ToastTransitionProps) {\n const enterClassName = appendPosition ? `${enter}--${position}` : enter;\n const exitClassName = appendPosition ? `${exit}--${position}` : exit;\n const baseClassName = useRef();\n const animationStep = useRef(AnimationStep.Enter);\n\n useLayoutEffect(() => {\n onEnter();\n }, []);\n\n useEffect(() => {\n if (!isIn) preventExitTransition ? onExited() : onExit();\n }, [isIn]);\n\n function onEnter() {\n const node = nodeRef.current!;\n baseClassName.current = node.className;\n node.className += ` ${enterClassName}`;\n node.addEventListener('animationend', onEntered);\n }\n\n function onEntered(e: AnimationEvent) {\n if (e.target !== nodeRef.current) return;\n\n const node = nodeRef.current!;\n node.removeEventListener('animationend', onEntered);\n if (animationStep.current === AnimationStep.Enter) {\n node.className = baseClassName.current!;\n }\n }\n\n function onExit() {\n animationStep.current = AnimationStep.Exit;\n const node = nodeRef.current!;\n\n node.className += ` ${exitClassName}`;\n node.addEventListener('animationend', onExited);\n }\n\n function onExited() {\n const node = nodeRef.current!;\n\n node.removeEventListener('animationend', onExited);\n collapse ? collapseToast(node, done, collapseDuration) : done();\n }\n\n return <>{children};\n };\n}\n","import { Default } from './constant';\n\n/**\n * Used to collapse toast after exit animation\n */\nexport function collapseToast(\n node: HTMLElement,\n done: () => void,\n duration = Default.COLLAPSE_DURATION\n) {\n const { scrollHeight, style } = node;\n\n requestAnimationFrame(() => {\n style.minHeight = 'initial';\n style.height = scrollHeight + 'px';\n style.transition = `all ${duration}ms`;\n\n requestAnimationFrame(() => {\n style.height = '0';\n style.padding = '0';\n style.margin = '0';\n setTimeout(done, duration as number);\n });\n });\n}\n","import {\n Id,\n ToastContent,\n ClearWaitingQueueParams,\n NotValidatedToastProps\n} from '../types';\nimport { ContainerInstance } from '../hooks';\n\nexport const enum Event {\n Show,\n Clear,\n DidMount,\n WillUnmount,\n Change,\n ClearWaitingQueue\n}\n\ntype OnShowCallback = (\n content: ToastContent,\n options: NotValidatedToastProps\n) => void;\ntype OnClearCallback = (id?: Id) => void;\ntype OnClearWaitingQueue = (params: ClearWaitingQueueParams) => void;\ntype OnDidMountCallback = (containerInstance: ContainerInstance) => void;\ntype OnWillUnmountCallback = OnDidMountCallback;\nexport type OnChangeCallback = (\n toast: number,\n containerId?: number | string\n) => void;\ntype Callback =\n | OnShowCallback\n | OnClearCallback\n | OnClearWaitingQueue\n | OnDidMountCallback\n | OnWillUnmountCallback\n | OnChangeCallback;\ntype TimeoutId = ReturnType;\n\nexport interface EventManager {\n list: Map;\n emitQueue: Map;\n on(event: Event.Show, callback: OnShowCallback): EventManager;\n on(event: Event.Clear, callback: OnClearCallback): EventManager;\n on(\n event: Event.ClearWaitingQueue,\n callback: OnClearWaitingQueue\n ): EventManager;\n on(event: Event.DidMount, callback: OnDidMountCallback): EventManager;\n on(event: Event.WillUnmount, callback: OnWillUnmountCallback): EventManager;\n on(event: Event.Change, callback: OnChangeCallback): EventManager;\n off(event: Event, callback?: Callback): EventManager;\n cancelEmit(event: Event): EventManager;\n emit(\n event: Event.Show,\n content: React.ReactNode,\n options: NotValidatedToastProps\n ): void;\n emit(event: Event.Clear, id?: string | number): void;\n emit(event: Event.ClearWaitingQueue, params: ClearWaitingQueueParams): void;\n emit(event: Event.DidMount, containerInstance: ContainerInstance): void;\n emit(event: Event.WillUnmount, containerInstance: ContainerInstance): void;\n emit(event: Event.Change, toast: number, containerId?: number | string): void;\n}\n\nexport const eventManager: EventManager = {\n list: new Map(),\n emitQueue: new Map(),\n\n on(event: Event, callback: Callback) {\n this.list.has(event) || this.list.set(event, []);\n this.list.get(event)!.push(callback);\n return this;\n },\n\n off(event, callback) {\n if (callback) {\n const cb = this.list.get(event)!.filter(cb => cb !== callback);\n this.list.set(event, cb);\n return this;\n }\n this.list.delete(event);\n return this;\n },\n\n cancelEmit(event) {\n const timers = this.emitQueue.get(event);\n if (timers) {\n timers.forEach(clearTimeout);\n this.emitQueue.delete(event);\n }\n\n return this;\n },\n\n /**\n * Enqueue the event at the end of the call stack\n * Doing so let the user call toast as follow:\n * toast('1')\n * toast('2')\n * toast('3')\n * Without setTimemout the code above will not work\n */\n emit(event: Event, ...args: any[]) {\n this.list.has(event) &&\n this.list.get(event)!.forEach((callback: Callback) => {\n const timer: TimeoutId = setTimeout(() => {\n // @ts-ignore\n callback(...args);\n }, 0);\n\n this.emitQueue.has(event) || this.emitQueue.set(event, []);\n this.emitQueue.get(event)!.push(timer);\n });\n }\n};\n","import { useRef, useEffect } from 'react';\n\n/**\n * `useKeeper` is a helper around `useRef`.\n *\n * You don't need to access the `.current`property to get the value\n * If refresh is set to true. The ref will be updated every render\n */\nexport function useKeeper(arg: T, refresh = false) {\n const ref = useRef(arg);\n\n useEffect(() => {\n if (refresh) ref.current = arg;\n });\n\n return ref.current;\n}\n","import { Id } from '../types';\n\nimport { isToastIdValid } from '../utils';\n\nexport const enum ActionType {\n ADD,\n REMOVE\n}\nexport type State = Array;\nexport type Action =\n | { type: ActionType.ADD; toastId: Id; staleId?: Id }\n | { type: ActionType.REMOVE; toastId?: Id };\n\nexport function reducer(state: State, action: Action) {\n switch (action.type) {\n case ActionType.ADD:\n return [...state, action.toastId].filter(id => id !== action.staleId);\n case ActionType.REMOVE:\n return isToastIdValid(action.toastId)\n ? state.filter(id => id !== action.toastId)\n : [];\n }\n}\n","import {\n useEffect,\n useRef,\n useReducer,\n cloneElement,\n isValidElement\n} from 'react';\nimport {\n parseClassName,\n canBeRendered,\n isBool,\n isFn,\n isNum,\n isStr,\n isToastIdValid,\n getAutoCloseDelay,\n Direction,\n Default\n} from '../utils';\nimport { eventManager, Event } from '../core/eventManager';\n\nimport {\n Id,\n ToastContainerProps,\n ToastProps,\n ToastContent,\n Toast,\n ToastPosition,\n ClearWaitingQueueParams,\n NotValidatedToastProps,\n ToastTransition\n} from '../types';\nimport { useKeeper } from './useKeeper';\nimport { ActionType, reducer } from './toastContainerReducer';\n\ntype CollectionItem = Record;\ntype ToastToRender = Partial>;\n\ninterface QueuedToast {\n toastContent: ToastContent;\n toastProps: ToastProps;\n staleId?: Id;\n}\n\nexport interface ContainerInstance {\n toastKey: number;\n displayedToast: number;\n props: ToastContainerProps;\n containerId?: Id | null;\n isToastActive: (toastId: Id) => boolean;\n getToast: (id: Id) => Toast | null;\n}\n\nexport function useToastContainer(props: ToastContainerProps) {\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n const [toast, dispatch] = useReducer(reducer, []);\n const containerRef = useRef(null);\n let toastCount = useKeeper(0);\n let queue = useKeeper([]);\n const collection = useKeeper({});\n const instance = useKeeper({\n toastKey: 1,\n displayedToast: 0,\n props,\n containerId: null,\n isToastActive: isToastActive,\n getToast: id => collection[id] || null\n });\n\n useEffect(() => {\n instance.containerId = props.containerId;\n eventManager\n .cancelEmit(Event.WillUnmount)\n .on(Event.Show, buildToast)\n .on(Event.Clear, toastId => containerRef.current && removeToast(toastId))\n .on(Event.ClearWaitingQueue, clearWaitingQueue)\n .emit(Event.DidMount, instance);\n\n return () => eventManager.emit(Event.WillUnmount, instance);\n }, []);\n\n useEffect(() => {\n instance.isToastActive = isToastActive;\n instance.displayedToast = toast.length;\n eventManager.emit(Event.Change, toast.length, props.containerId);\n }, [toast]);\n\n useEffect(() => {\n instance.props = props;\n });\n\n function isToastActive(id: Id) {\n return toast.indexOf(id) !== -1;\n }\n\n function clearWaitingQueue({ containerId }: ClearWaitingQueueParams) {\n const { limit } = instance.props;\n if (limit && (!containerId || instance.containerId === containerId)) {\n toastCount -= queue.length;\n queue = [];\n }\n }\n\n function removeToast(toastId?: Id) {\n dispatch({ type: ActionType.REMOVE, toastId });\n }\n\n function dequeueToast() {\n const { toastContent, toastProps, staleId } = queue.shift() as QueuedToast;\n appendToast(toastContent, toastProps, staleId);\n }\n\n /**\n * check if a container is attached to the dom\n * check for multi-container, build only if associated\n * check for duplicate toastId if no update\n */\n function isNotValid({\n containerId,\n toastId,\n updateId\n }: NotValidatedToastProps) {\n return !containerRef.current ||\n (instance.props.enableMultiContainer &&\n containerId !== instance.props.containerId) ||\n (collection[toastId] && updateId == null)\n ? true\n : false;\n }\n\n // this function and all the function called inside needs to rely on ref(`useKeeper`)\n function buildToast(\n content: ToastContent,\n { delay, staleId, ...options }: NotValidatedToastProps\n ) {\n if (!canBeRendered(content) || isNotValid(options)) return;\n\n const { toastId, updateId, data } = options;\n const { props } = instance;\n const closeToast = () => removeToast(toastId);\n const isNotAnUpdate = options.updateId == null;\n\n if (isNotAnUpdate) toastCount++;\n\n const toastProps: ToastProps = {\n toastId,\n updateId,\n isLoading: options.isLoading,\n theme: options.theme || props.theme!,\n icon: options.icon ?? props.icon,\n isIn: false,\n key: options.key || instance.toastKey++,\n type: options.type!,\n closeToast: closeToast,\n closeButton: options.closeButton,\n rtl: props.rtl,\n position: options.position || (props.position as ToastPosition),\n transition: options.transition || (props.transition as ToastTransition),\n className: parseClassName(options.className || props.toastClassName),\n bodyClassName: parseClassName(\n options.bodyClassName || props.bodyClassName\n ),\n style: options.style || props.toastStyle,\n bodyStyle: options.bodyStyle || props.bodyStyle,\n onClick: options.onClick || props.onClick,\n pauseOnHover: isBool(options.pauseOnHover)\n ? options.pauseOnHover\n : props.pauseOnHover,\n pauseOnFocusLoss: isBool(options.pauseOnFocusLoss)\n ? options.pauseOnFocusLoss\n : props.pauseOnFocusLoss,\n draggable: isBool(options.draggable)\n ? options.draggable\n : props.draggable,\n draggablePercent: isNum(options.draggablePercent)\n ? options.draggablePercent\n : (props.draggablePercent as number),\n draggableDirection:\n options.draggableDirection || props.draggableDirection,\n closeOnClick: isBool(options.closeOnClick)\n ? options.closeOnClick\n : props.closeOnClick,\n progressClassName: parseClassName(\n options.progressClassName || props.progressClassName\n ),\n progressStyle: options.progressStyle || props.progressStyle,\n autoClose: options.isLoading\n ? false\n : getAutoCloseDelay(options.autoClose, props.autoClose),\n hideProgressBar: isBool(options.hideProgressBar)\n ? options.hideProgressBar\n : props.hideProgressBar,\n progress: options.progress,\n role: isStr(options.role) ? options.role : props.role,\n deleteToast() {\n removeFromCollection(toastId);\n }\n };\n\n if (isFn(options.onOpen)) toastProps.onOpen = options.onOpen;\n if (isFn(options.onClose)) toastProps.onClose = options.onClose;\n\n // tweak for vertical dragging\n if (\n toastProps.draggableDirection === Direction.Y &&\n toastProps.draggablePercent === Default.DRAGGABLE_PERCENT\n ) {\n (toastProps.draggablePercent as number) *= 1.5;\n }\n\n let closeButton = props.closeButton;\n\n if (options.closeButton === false || canBeRendered(options.closeButton)) {\n closeButton = options.closeButton;\n } else if (options.closeButton === true) {\n closeButton = canBeRendered(props.closeButton) ? props.closeButton : true;\n }\n\n toastProps.closeButton = closeButton;\n\n let toastContent = content;\n\n if (isValidElement(content) && !isStr(content.type)) {\n toastContent = cloneElement(content, {\n closeToast,\n toastProps,\n data\n });\n } else if (isFn(content)) {\n toastContent = content({ closeToast, toastProps, data });\n }\n\n // not handling limit + delay by design. Waiting for user feedback first\n if (\n props.limit &&\n props.limit > 0 &&\n toastCount > props.limit &&\n isNotAnUpdate\n ) {\n queue.push({ toastContent, toastProps, staleId });\n } else if (isNum(delay) && (delay as number) > 0) {\n setTimeout(() => {\n appendToast(toastContent, toastProps, staleId);\n }, delay);\n } else {\n appendToast(toastContent, toastProps, staleId);\n }\n }\n\n function appendToast(\n content: ToastContent,\n toastProps: ToastProps,\n staleId?: Id\n ) {\n const { toastId } = toastProps;\n\n if (staleId) delete collection[staleId];\n\n collection[toastId] = {\n content,\n props: toastProps\n };\n dispatch({\n type: ActionType.ADD,\n toastId,\n staleId\n });\n }\n\n function removeFromCollection(toastId: Id) {\n delete collection[toastId];\n const queueLen = queue.length;\n toastCount = isToastIdValid(toastId)\n ? toastCount - 1\n : toastCount - instance.displayedToast;\n\n if (toastCount < 0) toastCount = 0;\n\n if (queueLen > 0) {\n const freeSlot = isToastIdValid(toastId) ? 1 : instance.props.limit!;\n\n if (queueLen === 1 || freeSlot === 1) {\n instance.displayedToast++;\n dequeueToast();\n } else {\n const toDequeue = freeSlot > queueLen ? queueLen : freeSlot;\n instance.displayedToast = toDequeue;\n\n for (let i = 0; i < toDequeue; i++) dequeueToast();\n }\n } else {\n forceUpdate();\n }\n }\n\n function getToastToRender(\n cb: (position: ToastPosition, toastList: Toast[]) => T\n ) {\n const toastToRender: ToastToRender = {};\n const toastList = props.newestOnTop\n ? Object.keys(collection).reverse()\n : Object.keys(collection);\n\n for (let i = 0; i < toastList.length; i++) {\n const toast = collection[toastList[i]];\n const { position } = toast.props;\n toastToRender[position] || (toastToRender[position] = []);\n\n toastToRender[position]!.push(toast);\n }\n\n return (Object.keys(toastToRender) as Array).map(p =>\n cb(p, toastToRender[p]!)\n );\n }\n\n return {\n getToastToRender,\n collection,\n containerRef,\n isToastActive\n };\n}\n","import {\n useState,\n useRef,\n useEffect,\n isValidElement,\n DOMAttributes\n} from 'react';\n\nimport { isFn } from '../utils';\nimport { ToastProps } from '../types';\nimport { useKeeper } from './useKeeper';\nimport { Direction } from '../utils/constant';\n\ninterface Draggable {\n start: number;\n x: number;\n y: number;\n delta: number;\n removalDistance: number;\n canCloseOnClick: boolean;\n canDrag: boolean;\n boundingRect: DOMRect | null;\n}\n\ntype DragEvent = MouseEvent & TouchEvent;\n\nfunction getX(e: DragEvent) {\n return e.targetTouches && e.targetTouches.length >= 1\n ? e.targetTouches[0].clientX\n : e.clientX;\n}\n\nfunction getY(e: DragEvent) {\n return e.targetTouches && e.targetTouches.length >= 1\n ? e.targetTouches[0].clientY\n : e.clientY;\n}\n\nexport function useToast(props: ToastProps) {\n const [isRunning, setIsRunning] = useState(true);\n const [preventExitTransition, setPreventExitTransition] = useState(false);\n const toastRef = useRef(null);\n const drag = useKeeper({\n start: 0,\n x: 0,\n y: 0,\n delta: 0,\n removalDistance: 0,\n canCloseOnClick: true,\n canDrag: false,\n boundingRect: null\n });\n const syncProps = useKeeper(props, true);\n const { autoClose, pauseOnHover, closeToast, onClick, closeOnClick } = props;\n\n useEffect(() => {\n if (isFn(props.onOpen))\n props.onOpen(isValidElement(props.children) && props.children.props);\n\n return () => {\n if (isFn(syncProps.onClose))\n syncProps.onClose(\n isValidElement(syncProps.children) && syncProps.children.props\n );\n };\n }, []);\n\n useEffect(() => {\n props.draggable && bindDragEvents();\n return () => {\n props.draggable && unbindDragEvents();\n };\n }, [props.draggable]);\n\n useEffect(() => {\n props.pauseOnFocusLoss && bindFocusEvents();\n return () => {\n props.pauseOnFocusLoss && unbindFocusEvents();\n };\n }, [props.pauseOnFocusLoss]);\n\n function onDragStart(\n e: React.MouseEvent | React.TouchEvent\n ) {\n if (props.draggable) {\n const toast = toastRef.current!;\n drag.canCloseOnClick = true;\n drag.canDrag = true;\n drag.boundingRect = toast.getBoundingClientRect();\n toast.style.transition = '';\n drag.x = getX(e.nativeEvent as DragEvent);\n drag.y = getY(e.nativeEvent as DragEvent);\n\n if (props.draggableDirection === Direction.X) {\n drag.start = drag.x;\n drag.removalDistance =\n toast.offsetWidth * (props.draggablePercent / 100);\n } else {\n drag.start = drag.y;\n drag.removalDistance =\n toast.offsetHeight * (props.draggablePercent / 100);\n }\n }\n }\n\n function onDragTransitionEnd() {\n if (drag.boundingRect) {\n const { top, bottom, left, right } = drag.boundingRect;\n\n if (\n props.pauseOnHover &&\n drag.x >= left &&\n drag.x <= right &&\n drag.y >= top &&\n drag.y <= bottom\n ) {\n pauseToast();\n } else {\n playToast();\n }\n }\n }\n\n function playToast() {\n setIsRunning(true);\n }\n\n function pauseToast() {\n setIsRunning(false);\n }\n\n function bindFocusEvents() {\n if (!document.hasFocus()) pauseToast();\n\n window.addEventListener('focus', playToast);\n window.addEventListener('blur', pauseToast);\n }\n\n function unbindFocusEvents() {\n window.removeEventListener('focus', playToast);\n window.removeEventListener('blur', pauseToast);\n }\n\n function bindDragEvents() {\n document.addEventListener('mousemove', onDragMove);\n document.addEventListener('mouseup', onDragEnd);\n\n document.addEventListener('touchmove', onDragMove);\n document.addEventListener('touchend', onDragEnd);\n }\n\n function unbindDragEvents() {\n document.removeEventListener('mousemove', onDragMove);\n document.removeEventListener('mouseup', onDragEnd);\n\n document.removeEventListener('touchmove', onDragMove);\n document.removeEventListener('touchend', onDragEnd);\n }\n\n function onDragMove(e: MouseEvent | TouchEvent) {\n if (drag.canDrag) {\n e.preventDefault();\n\n const toast = toastRef.current!;\n if (isRunning) pauseToast();\n\n drag.x = getX(e as DragEvent);\n drag.y = getY(e as DragEvent);\n\n if (props.draggableDirection === Direction.X) {\n drag.delta = drag.x - drag.start;\n } else {\n drag.delta = drag.y - drag.start;\n }\n\n // prevent false positif during a toast click\n if (drag.start !== drag.x) drag.canCloseOnClick = false;\n\n toast.style.transform = `translate${props.draggableDirection}(${drag.delta}px)`;\n toast.style.opacity = `${1 -\n Math.abs(drag.delta / drag.removalDistance)}`;\n }\n }\n\n function onDragEnd() {\n const toast = toastRef.current!;\n if (drag.canDrag) {\n drag.canDrag = false;\n\n if (Math.abs(drag.delta) > drag.removalDistance) {\n setPreventExitTransition(true);\n props.closeToast();\n return;\n }\n\n toast.style.transition = 'transform 0.2s, opacity 0.2s';\n toast.style.transform = `translate${props.draggableDirection}(0)`;\n toast.style.opacity = '1';\n }\n }\n\n const eventHandlers: DOMAttributes = {\n onMouseDown: onDragStart,\n onTouchStart: onDragStart,\n onMouseUp: onDragTransitionEnd,\n onTouchEnd: onDragTransitionEnd\n };\n\n if (autoClose && pauseOnHover) {\n eventHandlers.onMouseEnter = pauseToast;\n eventHandlers.onMouseLeave = playToast;\n }\n\n // prevent toast from closing when user drags the toast\n if (closeOnClick) {\n eventHandlers.onClick = (e: React.MouseEvent) => {\n onClick && onClick(e);\n drag.canCloseOnClick && closeToast();\n };\n }\n\n return {\n playToast,\n pauseToast,\n isRunning,\n preventExitTransition,\n toastRef,\n eventHandlers\n };\n}\n","import * as React from 'react';\nimport { Default } from '../utils';\nimport { Theme, TypeOptions } from '../types';\n\nexport interface CloseButtonProps {\n closeToast: (e: React.MouseEvent) => void;\n type: TypeOptions;\n ariaLabel?: string;\n theme: Theme;\n}\n\nexport function CloseButton({\n closeToast,\n theme,\n ariaLabel = 'close'\n}: CloseButtonProps) {\n return (\n {\n e.stopPropagation();\n closeToast(e);\n }}\n aria-label={ariaLabel}\n >\n \n \n \n \n );\n}\n","import * as React from 'react';\nimport cx from 'clsx';\n\nimport { TYPE, Default, isFn } from './../utils';\nimport { TypeOptions, ToastClassName, Theme } from '../types';\n\nexport interface ProgressBarProps {\n /**\n * The animation delay which determine when to close the toast\n */\n delay: number;\n\n /**\n * Whether or not the animation is running or paused\n */\n isRunning: boolean;\n\n /**\n * Func to close the current toast\n */\n closeToast: () => void;\n\n /**\n * Optional type : info, success ...\n */\n type: TypeOptions;\n\n /**\n * The theme that is currently used\n */\n theme: Theme;\n\n /**\n * Hide or not the progress bar\n */\n hide?: boolean;\n\n /**\n * Optionnal className\n */\n className?: ToastClassName;\n\n /**\n * Optionnal inline style\n */\n style?: React.CSSProperties;\n\n /**\n * Tell wether or not controlled progress bar is used\n */\n controlledProgress?: boolean;\n\n /**\n * Controlled progress value\n */\n progress?: number | string;\n\n /**\n * Support rtl content\n */\n rtl?: boolean;\n\n /**\n * Tell if the component is visible on screen or not\n */\n isIn?: boolean;\n}\n\nexport function ProgressBar({\n delay,\n isRunning,\n closeToast,\n type,\n hide,\n className,\n style: userStyle,\n controlledProgress,\n progress,\n rtl,\n isIn,\n theme\n}: ProgressBarProps) {\n const style: React.CSSProperties = {\n ...userStyle,\n animationDuration: `${delay}ms`,\n animationPlayState: isRunning ? 'running' : 'paused',\n opacity: hide ? 0 : 1\n };\n\n if (controlledProgress) style.transform = `scaleX(${progress})`;\n const defaultClassName = cx(\n `${Default.CSS_NAMESPACE}__progress-bar`,\n controlledProgress\n ? `${Default.CSS_NAMESPACE}__progress-bar--controlled`\n : `${Default.CSS_NAMESPACE}__progress-bar--animated`,\n `${Default.CSS_NAMESPACE}__progress-bar-theme--${theme}`,\n `${Default.CSS_NAMESPACE}__progress-bar--${type}`,\n {\n [`${Default.CSS_NAMESPACE}__progress-bar--rtl`]: rtl\n }\n );\n const classNames = isFn(className)\n ? className({\n rtl,\n type,\n defaultClassName\n })\n : cx(defaultClassName, className);\n\n // 🧐 controlledProgress is derived from progress\n // so if controlledProgress is set\n // it means that this is also the case for progress\n const animationEvent = {\n [controlledProgress && progress! >= 1\n ? 'onTransitionEnd'\n : 'onAnimationEnd']:\n controlledProgress && progress! < 1\n ? null\n : () => {\n isIn && closeToast();\n }\n };\n\n // TODO: add aria-valuenow, aria-valuemax, aria-valuemin\n\n return (\n \n );\n}\n\nProgressBar.defaultProps = {\n type: TYPE.DEFAULT,\n hide: false\n};\n","import React from 'react';\n\nimport { Theme, TypeOptions } from '../types';\nimport { Default } from '../utils';\n\n/**\n * Used when providing custom icon\n */\nexport interface IconProps {\n theme: Theme;\n type: TypeOptions;\n}\n\nexport type BuiltInIconProps = React.SVGProps & IconProps;\n\nconst Svg: React.FC = ({ theme, type, ...rest }) => (\n \n);\n\nfunction Warning(props: BuiltInIconProps) {\n return (\n \n \n \n );\n}\n\nfunction Info(props: BuiltInIconProps) {\n return (\n \n \n \n );\n}\n\nfunction Success(props: BuiltInIconProps) {\n return (\n \n \n \n );\n}\n\nfunction Error(props: BuiltInIconProps) {\n return (\n \n \n \n );\n}\n\nfunction Spinner() {\n return
;\n}\n\nexport const Icons = {\n info: Info,\n warning: Warning,\n success: Success,\n error: Error,\n spinner: Spinner\n};\n","import * as React from 'react';\nimport cx from 'clsx';\n\nimport { ProgressBar } from './ProgressBar';\nimport { Icons } from './Icons';\nimport { ToastProps } from '../types';\nimport { Default, isFn, isStr } from '../utils';\nimport { useToast } from '../hooks';\n\nexport const Toast: React.FC = props => {\n const {\n isRunning,\n preventExitTransition,\n toastRef,\n eventHandlers\n } = useToast(props);\n const {\n closeButton,\n children,\n autoClose,\n onClick,\n type,\n hideProgressBar,\n closeToast,\n transition: Transition,\n position,\n className,\n style,\n bodyClassName,\n bodyStyle,\n progressClassName,\n progressStyle,\n updateId,\n role,\n progress,\n rtl,\n toastId,\n deleteToast,\n isIn,\n isLoading,\n icon,\n theme\n } = props;\n const defaultClassName = cx(\n `${Default.CSS_NAMESPACE}__toast`,\n `${Default.CSS_NAMESPACE}__toast-theme--${theme}`,\n `${Default.CSS_NAMESPACE}__toast--${type}`,\n {\n [`${Default.CSS_NAMESPACE}__toast--rtl`]: rtl\n }\n );\n const cssClasses = isFn(className)\n ? className({\n rtl,\n position,\n type,\n defaultClassName\n })\n : cx(defaultClassName, className);\n const isProgressControlled = !!progress;\n const maybeIcon = Icons[type as keyof typeof Icons];\n const iconProps = { theme, type };\n let Icon: React.ReactNode = maybeIcon && maybeIcon(iconProps);\n\n if (icon === false) {\n Icon = void 0;\n } else if (isFn(icon)) {\n Icon = icon(iconProps);\n } else if (React.isValidElement(icon)) {\n Icon = React.cloneElement(icon, iconProps);\n } else if (isStr(icon)) {\n Icon = icon;\n } else if (isLoading) {\n Icon = Icons.spinner();\n }\n\n function renderCloseButton(closeButton: any) {\n if (!closeButton) return;\n\n const props = { closeToast, type, theme };\n\n if (isFn(closeButton)) return closeButton(props);\n\n if (React.isValidElement(closeButton))\n return React.cloneElement(closeButton, props);\n }\n\n return (\n \n \n \n {Icon && (\n \n {Icon}\n
\n )}\n
{children}
\n \n {renderCloseButton(closeButton)}\n {(autoClose || isProgressControlled) && (\n \n )}\n \n \n );\n};\n","import { Default, cssTransition } from '../utils';\n\nconst Bounce = cssTransition({\n enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__bounce-enter`,\n exit: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__bounce-exit`,\n appendPosition: true\n});\n\nconst Slide = cssTransition({\n enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__slide-enter`,\n exit: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__slide-exit`,\n appendPosition: true\n});\n\nconst Zoom = cssTransition({\n enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__zoom-enter`,\n exit: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__zoom-exit`\n});\n\nconst Flip = cssTransition({\n enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__flip-enter`,\n exit: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__flip-exit`\n});\n\nexport { Bounce, Slide, Zoom, Flip };\n","import * as React from 'react';\nimport cx from 'clsx';\n\nimport { Toast } from './Toast';\nimport { CloseButton } from './CloseButton';\nimport { Bounce } from './Transitions';\nimport { POSITION, Direction, Default, parseClassName, isFn } from '../utils';\nimport { useToastContainer } from '../hooks';\nimport { ToastContainerProps, ToastPosition } from '../types';\n\nexport const ToastContainer: React.FC = props => {\n const { getToastToRender, containerRef, isToastActive } = useToastContainer(\n props\n );\n const { className, style, rtl, containerId } = props;\n\n function getClassName(position: ToastPosition) {\n const defaultClassName = cx(\n `${Default.CSS_NAMESPACE}__toast-container`,\n `${Default.CSS_NAMESPACE}__toast-container--${position}`,\n { [`${Default.CSS_NAMESPACE}__toast-container--rtl`]: rtl }\n );\n return isFn(className)\n ? className({\n position,\n rtl,\n defaultClassName\n })\n : cx(defaultClassName, parseClassName(className));\n }\n\n return (\n \n {getToastToRender((position, toastList) => {\n const containerStyle: React.CSSProperties =\n toastList.length === 0\n ? { ...style, pointerEvents: 'none' }\n : { ...style };\n\n return (\n \n {toastList.map(({ content, props: toastProps }) => {\n return (\n \n {content}\n \n );\n })}\n \n );\n })}\n \n );\n};\n\nToastContainer.defaultProps = {\n position: POSITION.TOP_RIGHT as ToastPosition,\n transition: Bounce,\n rtl: false,\n autoClose: 5000,\n hideProgressBar: false,\n closeButton: CloseButton,\n pauseOnHover: true,\n pauseOnFocusLoss: true,\n closeOnClick: true,\n newestOnTop: false,\n draggable: true,\n draggablePercent: Default.DRAGGABLE_PERCENT as number,\n draggableDirection: Direction.X,\n role: 'alert',\n theme: 'light'\n};\n","import * as React from 'react';\nimport { render } from 'react-dom';\n\nimport { POSITION, TYPE, canUseDom, isStr, isNum, isFn } from '../utils';\nimport { eventManager, OnChangeCallback, Event } from './eventManager';\nimport {\n ToastContent,\n ToastOptions,\n ToastProps,\n Id,\n ToastContainerProps,\n UpdateOptions,\n ClearWaitingQueueParams,\n NotValidatedToastProps,\n TypeOptions\n} from '../types';\nimport { ContainerInstance } from '../hooks';\nimport { ToastContainer } from '../components';\n\ninterface EnqueuedToast {\n content: ToastContent;\n options: NotValidatedToastProps;\n}\n\nlet containers = new Map();\nlet latestInstance: ContainerInstance | Id;\nlet containerDomNode: HTMLElement;\nlet containerConfig: ToastContainerProps;\nlet queue: EnqueuedToast[] = [];\nlet lazy = false;\n\n/**\n * Check whether any container is currently mounted in the DOM\n */\nfunction isAnyContainerMounted() {\n return containers.size > 0;\n}\n\n/**\n * Get the toast by id, given it's in the DOM, otherwise returns null\n */\nfunction getToast(toastId: Id, { containerId }: ToastOptions) {\n const container = containers.get(containerId || latestInstance);\n if (!container) return null;\n\n return container.getToast(toastId);\n}\n\n/**\n * Generate a random toastId\n */\nfunction generateToastId() {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n\n/**\n * Generate a toastId or use the one provided\n */\nfunction getToastId(options?: ToastOptions) {\n if (options && (isStr(options.toastId) || isNum(options.toastId))) {\n return options.toastId;\n }\n\n return generateToastId();\n}\n\n/**\n * If the container is not mounted, the toast is enqueued and\n * the container lazy mounted\n */\nfunction dispatchToast(\n content: ToastContent,\n options: NotValidatedToastProps\n): Id {\n if (isAnyContainerMounted()) {\n eventManager.emit(Event.Show, content, options);\n } else {\n queue.push({ content, options });\n if (lazy && canUseDom) {\n lazy = false;\n containerDomNode = document.createElement('div');\n document.body.appendChild(containerDomNode);\n render(, containerDomNode);\n }\n }\n\n return options.toastId;\n}\n\n/**\n * Merge provided options with the defaults settings and generate the toastId\n */\nfunction mergeOptions(type: string, options?: ToastOptions) {\n return {\n ...options,\n type: (options && options.type) || type,\n toastId: getToastId(options)\n } as NotValidatedToastProps;\n}\n\nconst createToastByType = (type: string) => (\n content: ToastContent,\n options?: ToastOptions\n) => dispatchToast(content, mergeOptions(type, options));\n\nconst toast = (content: ToastContent, options?: ToastOptions) =>\n dispatchToast(content, mergeOptions(TYPE.DEFAULT, options));\n\ntoast.loading = (content: ToastContent, options?: ToastOptions) =>\n dispatchToast(\n content,\n mergeOptions(TYPE.DEFAULT, {\n isLoading: true,\n autoClose: false,\n closeOnClick: false,\n closeButton: false,\n draggable: false,\n ...options\n })\n );\n\ninterface ToastPromiseParams {\n pending: string | UpdateOptions;\n success: string | UpdateOptions;\n error: string | UpdateOptions;\n}\n\nfunction handlePromise(\n promise: Promise | (() => Promise),\n { pending, error, success }: ToastPromiseParams,\n options?: ToastOptions\n) {\n const id = isStr(pending)\n ? toast.loading(pending, options)\n : toast.loading(pending.render, {\n ...options,\n ...(pending as ToastOptions)\n });\n const resetParams = {\n isLoading: null,\n autoClose: null,\n closeOnClick: null,\n closeButton: null,\n draggable: null\n };\n\n const resolver = (\n type: TypeOptions,\n input: string | UpdateOptions,\n result: T\n ) => {\n const params = isStr(input) ? { render: input } : input;\n toast.update(id, {\n type,\n ...resetParams,\n ...options,\n ...params,\n data: result\n });\n return result;\n };\n const p = isFn(promise) ? promise() : promise;\n p.then(result => resolver('success', success, result)).catch(err =>\n resolver('error', error, err)\n );\n\n return p;\n}\n\ntoast.promise = handlePromise;\ntoast.success = createToastByType(TYPE.SUCCESS);\ntoast.info = createToastByType(TYPE.INFO);\ntoast.error = createToastByType(TYPE.ERROR);\ntoast.warning = createToastByType(TYPE.WARNING);\ntoast.warn = toast.warning;\ntoast.dark = (content: ToastContent, options?: ToastOptions) =>\n dispatchToast(\n content,\n mergeOptions(TYPE.DEFAULT, {\n theme: 'dark',\n ...options\n })\n );\n\n/**\n * Remove toast programmaticaly\n */\ntoast.dismiss = (id?: Id) => eventManager.emit(Event.Clear, id);\n\n/**\n * Clear waiting queue when limit is used\n */\ntoast.clearWaitingQueue = (params: ClearWaitingQueueParams = {}) =>\n eventManager.emit(Event.ClearWaitingQueue, params);\n\n/**\n * return true if one container is displaying the toast\n */\ntoast.isActive = (id: Id) => {\n let isToastActive = false;\n\n containers.forEach(container => {\n if (container.isToastActive && container.isToastActive(id)) {\n isToastActive = true;\n }\n });\n\n return isToastActive;\n};\n\ntoast.update = (toastId: Id, options: UpdateOptions = {}) => {\n // if you call toast and toast.update directly nothing will be displayed\n // this is why I defered the update\n setTimeout(() => {\n const toast = getToast(toastId, options as ToastOptions);\n if (toast) {\n const { props: oldOptions, content: oldContent } = toast;\n\n const nextOptions = {\n ...oldOptions,\n ...options,\n toastId: options.toastId || toastId,\n updateId: generateToastId()\n } as ToastProps & UpdateOptions;\n\n if (nextOptions.toastId !== toastId) nextOptions.staleId = toastId;\n\n const content = nextOptions.render || oldContent;\n delete nextOptions.render;\n\n dispatchToast(content, nextOptions);\n }\n }, 0);\n};\n\n/**\n * Used for controlled progress bar.\n */\ntoast.done = (id: Id) => {\n toast.update(id, {\n progress: 1\n });\n};\n\n/**\n * Track changes. The callback get the number of toast displayed\n *\n */\ntoast.onChange = (callback: OnChangeCallback) => {\n if (isFn(callback)) {\n eventManager.on(Event.Change, callback);\n }\n return () => {\n isFn(callback) && eventManager.off(Event.Change, callback);\n };\n};\n\n/**\n * Configure the ToastContainer when lazy mounted\n */\ntoast.configure = (config: ToastContainerProps = {}) => {\n lazy = true;\n containerConfig = config;\n};\n\ntoast.POSITION = POSITION;\ntoast.TYPE = TYPE;\n\n/**\n * Wait until the ToastContainer is mounted to dispatch the toast\n * and attach isActive method\n */\neventManager\n .on(Event.DidMount, (containerInstance: ContainerInstance) => {\n latestInstance = containerInstance.containerId || containerInstance;\n containers.set(latestInstance, containerInstance);\n\n queue.forEach(item => {\n eventManager.emit(Event.Show, item.content, item.options);\n });\n\n queue = [];\n })\n .on(Event.WillUnmount, (containerInstance: ContainerInstance) => {\n containers.delete(containerInstance.containerId || containerInstance);\n\n if (containers.size === 0) {\n eventManager\n .off(Event.Show)\n .off(Event.Clear)\n .off(Event.ClearWaitingQueue);\n }\n\n if (canUseDom && containerDomNode) {\n document.body.removeChild(containerDomNode);\n }\n });\n\nexport { toast };\n"],"sourceRoot":""}