{"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","notifyNextPageLoad","dequeueForNextPageLoad","forEach","n","message","error","nextPageLoad","enqueueForNextPageLoad","success","warning","open","localStorageItem","localStorage","getItem","length","JSON","parse","push","setItem","stringify","removeItem"],"mappings":"OAASA,UAA+C,kDAC/CC,iBAAoB,gCACpBC,0BAA6B,uBAEzBC,OAITC,YAAYC,EAAmB,KAC3BJ,aAAaC,sBAAsBI,OAAOC,KAAKC,IAAK,2CAEpDC,KAAKC,QAAU,CACXL,SAAUA,EACVM,SAAU,CACNC,EAAG,SACHC,EAAG,OAEPC,MAAO,CACH,CACEC,KAAM,OACNC,WAAY,SACZC,MAAM,IAGZC,aAAa,GAGjBT,KAAKU,MAAQ,IAAInB,MAAMS,KAAKC,SAE5B,MAAMU,EAAqBX,KAAKY,yBAChCD,GAAoBE,QAAQ,IACxBb,KAAKc,EAAER,MAAMQ,EAAEC,WAMhBC,MAAMD,EAAiBE,GAAwB,GAClD,OAAIA,GACAjB,KAAKkB,uBAAuB,QAASH,GAC9B,MAGJf,KAAKU,MAAMM,MAAM,CACpBV,KAAM,QACNS,QAASA,EACTnB,SAAU,OAIXuB,QAAQJ,EAAiBE,GAAwB,GACpD,OAAIA,GACAjB,KAAKkB,uBAAuB,UAAWH,GAChC,MAGJf,KAAKU,MAAMS,QAAQJ,GAGvBK,QAAQL,EAAiBE,GAAwB,GACpD,OAAIA,GACAjB,KAAKkB,uBAAuB,UAAWH,GAChC,MAGJf,KAAKU,MAAMW,KACd,CACIf,KAAM,OACNS,QAASA,EACTnB,SAAU,MAQdsB,uBAAuBZ,EAAcS,GACzC,IAAMO,EAAmBC,aAAaC,QAAQ,yBAC9C,MAAMb,EAAqBW,GAAkBG,OAASC,KAAKC,MAAML,GAAoB,GACrFX,EAAmBiB,KAAK,CAAEtB,KAAMA,EAAMS,QAASA,IAC/CQ,aAAaM,QAAQ,wBAAyBH,KAAKI,UAAUnB,IAGzDC,yBACJ,IAAMU,EAAmBC,aAAaC,QAAQ,yBACxCb,EAAqBW,GAAkBG,OAASC,KAAKC,MAAML,GAAoB,GAErF,OADAC,aAAaQ,WAAW,yBACjBpB,UApFFjB","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}"]}