{"version":3,"sources":["utils/notify.ts"],"names":["Notyf","cssTagLoader","getModuleRelativePath","loadNotyfCss","import","meta","url","Notify","constructor","instance","this","_initNoty","error","message","nextPageLoad","enqueueForNextPageLoad","notyf","type","duration","success","warning","open","className","getInstance","options","ripple","position","x","y","types","background","icon","tagName","text","dismissible","dequeueForNextPageLoad","forEach","n","localStorageItem","localStorage","getItem","notifyNextPageLoad","length","JSON","parse","push","setItem","stringify","removeItem"],"mappings":"OAASA,KAAyF,KAA1C,kDAC/CC,YAA4C,KAAxB,gCACpBC,qBAA6C,KAAhB,iBAEhC,SAAUC,eACZF,aAAaC,sBAAsBE,OAAOC,KAAKC,IAAK,wCAAwC,CAAC,CACjG,OACaC,OAKTC,cAMI,OAJKD,OAAOE,WACRF,OAAOE,SAAWC,MACbC,UAAS,EAEXJ,OAAOE,QAClB,CAIOG,MAAMC,EAAiBC,EAAwB,CAAA,GAClD,OAAIA,GACAJ,KAAKK,uBAAuB,QAASF,CAAO,EACrC,MAGJH,KAAKM,MAAMJ,MAAM,CACpBK,KAAM,QACNJ,QAASA,EACTK,SAAU,I,CACb,CACL,CAEOC,QAAQN,EAAiBC,EAAwB,CAAA,GACpD,OAAIA,GACAJ,KAAKK,uBAAuB,UAAWF,CAAO,EACvC,MAGJH,KAAKM,MAAMG,QAAQN,CAAO,CACrC,CAEOO,QAAQP,EAAiBC,EAAwB,CAAA,GACpD,OAAIA,GACAJ,KAAKK,uBAAuB,UAAWF,CAAO,EACvC,MAGJH,KAAKM,MAAMK,KACd,CACIJ,KAAM,UACNJ,QAASA,EACTS,UAAW,wBACXJ,SAAU,G,CACb,CAET,CAEOK,qBAIH,OAHKhB,OAAOE,WACRF,OAAOE,SAAW,IAAIF,QAEnBA,OAAOE,QAClB,CAKQE,YACJR,aAAY,EAEZO,KAAKc,QAAU,CACXN,SAAU,IACVO,OAAQ,CAAA,EACRC,SAAU,CACNC,EAAG,SACHC,EAAG,K,EAEPC,MAAO,CACH,CACEZ,KAAM,UACNa,WAAY,SACZC,KAAM,CACJT,UAAW,uBACXU,QAAS,IACTC,KAAM,S,IAIdC,YAAa,CAAA,C,EAGjBxB,KAAKM,MAAQ,IAAIhB,MAAMU,KAAKc,OAAO,EAERd,KAAKyB,uBAAsB,GAClCC,QAAQ,IACxB1B,KAAK2B,EAAEpB,MAAMoB,EAAExB,OAAO,CAC1B,CAAC,CACL,CAEQE,uBAAuBE,EAAcJ,GACzC,IAAMyB,EAAmBC,aAAaC,QAAQ,uBAAuB,EAC/DC,EAAqBH,GAAkBI,OAASC,KAAKC,MAAMN,CAAgB,EAAI,GACrFG,EAAmBI,KAAK,CAAE5B,KAAMA,EAAMJ,QAASA,CAAO,CAAE,EACxD0B,aAAaO,QAAQ,wBAAyBH,KAAKI,UAAUN,CAAkB,CAAC,CACpF,CAEQN,yBACJ,IAAMG,EAAmBC,aAAaC,QAAQ,uBAAuB,EAC/DC,EAAqBH,GAAkBI,OAASC,KAAKC,MAAMN,CAAgB,EAAI,GAErF,OADAC,aAAaS,WAAW,uBAAuB,EACxCP,CACX,C,QA/GYtC,aAGHI,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 function loadNotyfCss() {\r\n cssTagLoader(getModuleRelativePath(import.meta.url, \"../../node_modules/notyf/notyf.min.css\"));\r\n}\r\nexport class Notify {\r\n private static instance: Notify;\r\n private options: INotyfOptions;\r\n private notyf: Notyf;\r\n\r\n constructor() {\r\n \r\n if (!Notify.instance) {\r\n Notify.instance = this;\r\n this._initNoty();\r\n }\r\n return Notify.instance as Notify;\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: 'warning',\r\n message: message,\r\n className: 'notyf__toast--warning',\r\n duration: 10000\r\n }\r\n );\r\n }\r\n\r\n public static getInstance(): Notify {\r\n if (!Notify.instance) {\r\n Notify.instance = new Notify();\r\n }\r\n return Notify.instance;\r\n }\r\n\r\n /* #endregion */\r\n\r\n /* #region Private */\r\n private _initNoty() {\r\n loadNotyfCss();\r\n \r\n this.options = {\r\n duration: 7000,\r\n ripple: false, //While we do use jQuery Noty we have to disable ripple effect at notyF, to have more consistent look and feel.\r\n position: {\r\n x: \"center\",\r\n y: \"top\"\r\n },\r\n types: [\r\n {\r\n type: 'warning',\r\n background: 'orange',\r\n icon: {\r\n className: 'notyf__icon--warning',\r\n tagName: 'i',\r\n text: 'warning'\r\n }\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 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}"]}