{"version":3,"sources":["utils/notify.ts"],"names":["Notyf","cssTagLoader","getModuleRelativePath","Notify","constructor","duration","import","meta","url","this","options","position","x","y","types","type","background","icon","dismissible","notyf","dequeueForNextPageLoad","forEach","n","message","error","nextPageLoad","enqueueForNextPageLoad","success","warning","open","localStorageItem","localStorage","getItem","notifyNextPageLoad","length","JSON","parse","push","setItem","stringify","removeItem"],"mappings":"OAASA,KAAyF,KAA1C,kDAC/CC,YAA4C,KAAxB,gCACpBC,qBAA6C,KAAhB,uBAEzBC,OAITC,YAAYC,EAAmB,KAC3BJ,aAAaC,sBAAsBI,OAAOC,KAAKC,IAAK,wCAAwC,CAAC,EAE7FC,KAAKC,QAAU,CACXL,SAAUA,EACVM,SAAU,CACNC,EAAG,SACHC,EAAG,K,EAEPC,MAAO,CACH,CACEC,KAAM,OACNC,WAAY,SACZC,KAAM,CAAA,C,GAGZC,YAAa,CAAA,C,EAGjBT,KAAKU,MAAQ,IAAInB,MAAMS,KAAKC,OAAO,EAERD,KAAKW,uBAAsB,GAClCC,QAAQ,IACxBZ,KAAKa,EAAEP,MAAMO,EAAEC,OAAO,CAC1B,CAAC,CACL,CAIOC,MAAMD,EAAiBE,EAAwB,CAAA,GAClD,OAAIA,GACAhB,KAAKiB,uBAAuB,QAASH,CAAO,EACrC,MAGJd,KAAKU,MAAMK,MAAM,CACpBT,KAAM,QACNQ,QAASA,EACTlB,SAAU,I,CACb,CACL,CAEOsB,QAAQJ,EAAiBE,EAAwB,CAAA,GACpD,OAAIA,GACAhB,KAAKiB,uBAAuB,UAAWH,CAAO,EACvC,MAGJd,KAAKU,MAAMQ,QAAQJ,CAAO,CACrC,CAEOK,QAAQL,EAAiBE,EAAwB,CAAA,GACpD,OAAIA,GACAhB,KAAKiB,uBAAuB,UAAWH,CAAO,EACvC,MAGJd,KAAKU,MAAMU,KACd,CACId,KAAM,OACNQ,QAASA,EACTlB,SAAU,G,CACb,CAET,CAKQqB,uBAAuBX,EAAcQ,GACzC,IAAMO,EAAmBC,aAAaC,QAAQ,uBAAuB,EAC/DC,EAAqBH,GAAkBI,OAASC,KAAKC,MAAMN,CAAgB,EAAI,GACrFG,EAAmBI,KAAK,CAAEtB,KAAMA,EAAMQ,QAASA,CAAO,CAAE,EACxDQ,aAAaO,QAAQ,wBAAyBH,KAAKI,UAAUN,CAAkB,CAAC,CACpF,CAEQb,yBACJ,IAAMU,EAAmBC,aAAaC,QAAQ,uBAAuB,EAC/DC,EAAqBH,GAAkBI,OAASC,KAAKC,MAAMN,CAAgB,EAAI,GAErF,OADAC,aAAaS,WAAW,uBAAuB,EACxCP,CACX,C,QArFS9B,M","file":"notify.js","sourcesContent":["import { Notyf, INotyfOptions, NotyfNotification } from \"../../node_modules/notyf/notyf.es.min.js\";\r\nimport { cssTagLoader } from \"./script-tag-loader.js\";\r\nimport { getModuleRelativePath } from \"./url-utils.js\";\r\n\r\nexport class Notify {\r\n private options: INotyfOptions;\r\n private notyf: Notyf;\r\n\r\n constructor(duration: number = 7000) {\r\n cssTagLoader(getModuleRelativePath(import.meta.url, \"../../node_modules/notyf/notyf.min.css\"));\r\n\r\n this.options = {\r\n duration: duration,\r\n position: {\r\n x: \"center\",\r\n y: \"top\"\r\n },\r\n types: [\r\n {\r\n type: 'info',\r\n background: 'orange',\r\n icon: false\r\n }\r\n ],\r\n dismissible: true\r\n } as INotyfOptions;\r\n\r\n this.notyf = new Notyf(this.options);\r\n\r\n const notifyNextPageLoad = this.dequeueForNextPageLoad();\r\n notifyNextPageLoad?.forEach((n: { type: string, message: string }) => {\r\n this[n.type](n.message);\r\n });\r\n }\r\n\r\n /* #region Public */\r\n\r\n public error(message: string, nextPageLoad: boolean = false): NotyfNotification {\r\n if (nextPageLoad) {\r\n this.enqueueForNextPageLoad(\"error\", message);\r\n return null;\r\n }\r\n\r\n return this.notyf.error({\r\n type: 'error',\r\n message: message,\r\n duration: 14000\r\n });\r\n }\r\n\r\n public success(message: string, nextPageLoad: boolean = false): NotyfNotification {\r\n if (nextPageLoad) {\r\n this.enqueueForNextPageLoad(\"success\", message);\r\n return null;\r\n }\r\n\r\n return this.notyf.success(message);\r\n }\r\n\r\n public warning(message: string, nextPageLoad: boolean = false): NotyfNotification {\r\n if (nextPageLoad) {\r\n this.enqueueForNextPageLoad(\"warning\", message);\r\n return null;\r\n }\r\n\r\n return this.notyf.open(\r\n {\r\n type: 'info',\r\n message: message,\r\n duration: 10000\r\n }\r\n );\r\n }\r\n\r\n /* #endregion */\r\n\r\n /* #region Private */\r\n private enqueueForNextPageLoad(type: string, message: string) {\r\n const localStorageItem = localStorage.getItem(\"notify_next_page_load\");\r\n const notifyNextPageLoad = localStorageItem?.length ? JSON.parse(localStorageItem) : [];\r\n notifyNextPageLoad.push({ type: type, message: message });\r\n localStorage.setItem(\"notify_next_page_load\", JSON.stringify(notifyNextPageLoad));\r\n }\r\n\r\n private dequeueForNextPageLoad() {\r\n const localStorageItem = localStorage.getItem(\"notify_next_page_load\");\r\n const notifyNextPageLoad = localStorageItem?.length ? JSON.parse(localStorageItem) : [];\r\n localStorage.removeItem(\"notify_next_page_load\");\r\n return notifyNextPageLoad;\r\n }\r\n /* #endregion */\r\n}"]}