{"version":3,"file":"notification.mjs","names":["ref","NotificationQueue","_classCallCheck","_defineProperty","_createClass","key","value","enqueue","notification","queue","push","isActive","showNext","shift","currentNotification","closeNotification","_this","setTimeout","notificationQueue","useNotification","run","close","Notification","install","app","config","globalProperties","$useNotification","provide"],"sources":["../../../src/components/UNotification/notification.ts"],"sourcesContent":["import { App, Plugin, Ref, ref } from 'vue'\n\nexport interface NotificationOptions {\n  color?: string\n  iconLeft: string\n  iconTop?: string\n  title?: string\n  text?: string\n  buttons?: string\n  delay?: number\n  position?: string\n  elevation?: string\n  subTitle?: string\n}\n\nexport class NotificationQueue {\n  private queue: NotificationOptions[] = []\n  public isActive = ref(false)\n  public currentNotification = ref<NotificationOptions | null>(null)\n\n  enqueue(notification: NotificationOptions) {\n    this.queue.push(notification)\n    if (!this.isActive.value) {\n      this.showNext()\n    }\n  }\n\n  showNext() {\n    const notification = this.queue.shift()\n    if (notification) {\n      this.isActive.value = true\n      this.currentNotification.value = notification\n    }\n  }\n\n  closeNotification() {\n    this.isActive.value = false\n    this.currentNotification.value = null\n    setTimeout(() => {\n      this.showNext()\n    }, 300)\n  }\n}\n\nexport interface NotificationInstance {\n  isActive: Ref<boolean>\n  currentNotification: Ref<NotificationOptions | null>\n  run: (notification: NotificationOptions) => void\n  close: () => void\n}\n\nexport const notificationQueue = new NotificationQueue()\n\nexport const useNotification = (): NotificationInstance => {\n  return {\n    isActive: notificationQueue.isActive,\n    currentNotification: notificationQueue.currentNotification,\n    run: (notification: NotificationOptions) => {\n      notificationQueue.enqueue(notification)\n    },\n    close: () => {\n      notificationQueue.closeNotification()\n    },\n  }\n}\n\nexport const Notification: Plugin = {\n  install: (app: App) => {\n    app.config.globalProperties.$useNotification = useNotification()\n    app.provide('$useNotification', useNotification())\n  },\n}\n"],"mappings":";;;;;;;AAAA,SAA2BA,GAAG,QAAQ,KAAK;AAe3C,WAAaC,iBAAiB;EAAA,SAAAA,kBAAA;IAAAC,eAAA,OAAAD,iBAAA;IAAAE,eAA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