{
  "version": 3,
  "sources": ["../../../../src/lib/ui/hooks/useToastsProvider.tsx"],
  "sourcesContent": ["import { Editor, uniqueId } from '@bigbluebutton/editor'\nimport { createContext, useCallback, useContext, useState } from 'react'\nimport { TLUiIconType } from '../icon-types'\n\n/** @public */\nexport interface TLUiToast {\n\tid: string\n\ticon?: TLUiIconType\n\ttitle?: string\n\tdescription?: string\n\tactions?: TLUiToastAction[]\n\tkeepOpen?: boolean\n\tcloseLabel?: string\n}\n\n/** @public */\nexport interface TLUiToastAction {\n\ttype: 'primary' | 'danger' | 'normal'\n\tlabel: string\n\tonClick: () => void\n}\n\n/** @public */\nexport type TLUiToastsContextType = {\n\taddToast: (toast: Omit<TLUiToast, 'id'> & { id?: string }) => string\n\tremoveToast: (id: TLUiToast['id']) => string\n\tclearToasts: () => void\n\ttoasts: TLUiToast[]\n}\n\n/** @internal */\nexport const ToastsContext = createContext({} as TLUiToastsContextType)\n\n/** @internal */\nexport type ToastsProviderProps = {\n\toverrides?: (editor: Editor) => TLUiToastsContextType\n\tchildren: any\n}\n\n/** @internal */\nexport function ToastsProvider({ children }: ToastsProviderProps) {\n\tconst [toasts, setToasts] = useState<TLUiToast[]>([])\n\n\tconst addToast = useCallback((toast: Omit<TLUiToast, 'id'> & { id?: string }) => {\n\t\tconst id = toast.id ?? uniqueId()\n\t\tsetToasts((d) => [...d.filter((m) => m.id !== toast.id), { ...toast, id }])\n\t\treturn id\n\t}, [])\n\n\tconst removeToast = useCallback((id: string) => {\n\t\tsetToasts((d) => d.filter((m) => m.id !== id))\n\t\treturn id\n\t}, [])\n\n\tconst clearToasts = useCallback(() => {\n\t\tsetToasts(() => [])\n\t}, [])\n\n\treturn (\n\t\t<ToastsContext.Provider value={{ toasts, addToast, removeToast, clearToasts }}>\n\t\t\t{children}\n\t\t</ToastsContext.Provider>\n\t)\n}\n\n/** @public */\nexport function useToasts() {\n\tconst ctx = useContext(ToastsContext)\n\n\tif (!ctx) {\n\t\tthrow new Error('useToasts must be used within a ToastsProvider')\n\t}\n\n\treturn ctx\n}\n"],
  "mappings": "AA2DE;AA3DF,SAAiB,gBAAgB;AACjC,SAAS,eAAe,aAAa,YAAY,gBAAgB;AA8B1D,MAAM,gBAAgB,cAAc,CAAC,CAA0B;AAS/D,SAAS,eAAe,EAAE,SAAS,GAAwB;AACjE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAsB,CAAC,CAAC;AAEpD,QAAM,WAAW,YAAY,CAAC,UAAmD;AAChF,UAAM,KAAK,MAAM,MAAM,SAAS;AAChC,cAAU,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,GAAG,CAAC,CAAC;AAC1E,WAAO;AAAA,EACR,GAAG,CAAC,CAAC;AAEL,QAAM,cAAc,YAAY,CAAC,OAAe;AAC/C,cAAU,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7C,WAAO;AAAA,EACR,GAAG,CAAC,CAAC;AAEL,QAAM,cAAc,YAAY,MAAM;AACrC,cAAU,MAAM,CAAC,CAAC;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,SACC,oBAAC,cAAc,UAAd,EAAuB,OAAO,EAAE,QAAQ,UAAU,aAAa,YAAY,GAC1E,UACF;AAEF;AAGO,SAAS,YAAY;AAC3B,QAAM,MAAM,WAAW,aAAa;AAEpC,MAAI,CAAC,KAAK;AACT,UAAM,IAAI,MAAM,gDAAgD;AAAA,EACjE;AAEA,SAAO;AACR;",
  "names": []
}
