{"version":3,"sources":["webpack:///./cartridges/app_harmony/cartridge/client/default/js/widgets/product/NotifyMeForm.js"],"names":["AjaxForm","NotifyMeForm","prefs","notifyEmail","formButton","successMessage","accessibilityAnnouncementMsg","onSubmitted","data","success","ref","hide","setText","msg","show","eventBus","emit","accessibilityAlert","fieldErrors","Object","entries","forEach","name","errorMsg","getById","formField","setError","inputEmail"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;AAIA;;;;AAIe,yEAAUA,QAAV,EAAoB;AAC/B,QAAMC,YAAN,SAA2BD,QAA3B,CAAoC;AAChCE,SAAK,GAAG;AACJ,aAAO;AACHC,mBAAW,EAAE,sBADV;AAEHC,kBAAU,EAAE,YAFT;AAGHC,sBAAc,EAAE,gBAHb;AAIHC,oCAA4B,EAAE,EAJ3B;AAKH,WAAG,MAAMJ,KAAN;AALA,OAAP;AAOH;AAED;;;;;;;;AAMAK,eAAW,CAACC,IAAD,EAAO;AACd,UAAIA,IAAI,CAACC,OAAT,EAAkB;AACd,aAAKC,GAAL,CAAS,YAAT,EAAuBC,IAAvB;AACA,aAAKD,GAAL,CAAS,gBAAT,EACKE,OADL,CACaJ,IAAI,CAACK,GADlB,EAEKC,IAFL;AAGA;;;;;AAIA,aAAKC,QAAL,GAAgBC,IAAhB,CAAqB,YAArB,EAAmC;AAC/BC,4BAAkB,EAAE,KAAKf,KAAL,GAAaI;AADF,SAAnC;AAGH;;AAED,UAAI,CAACE,IAAI,CAACC,OAAV,EAAmB;AACf,YAAID,IAAI,CAACU,WAAT,EAAsB;AAClBC,gBAAM,CAACC,OAAP,CAAeZ,IAAI,CAACU,WAApB,EAAiCG,OAAjC,CAAyC,CAAC,CAACC,IAAD,EAAOC,QAAP,CAAD,KAAsB;AAC3D,iBAAKC,OAAL,CAAaF,IAAb,EAAmBG,SAAS,IAAIA,SAAS,CAACC,QAAV,CAAmBH,QAAnB,CAAhC;AACH,WAFD;AAGH;;AACD,YAAIf,IAAI,CAACK,GAAT,EAAc;AACV,eAAKW,OAAL,CAAa,KAAKtB,KAAL,GAAaC,WAA1B,EAAuCwB,UAAU,IAAIA,UAAU,CAACD,QAAX,CAAoBlB,IAAI,CAACK,GAAzB,CAArD;AACH;AACJ;AACJ;;AA1C+B;;AA6CpC,SAAOZ,YAAP;AACH,C","file":"6.bundle.js","sourcesContent":["/**\n * @typedef {ReturnType} AjaxForm\n */\n\n/**\n * @param {AjaxForm} AjaxForm Base widget for extending\n * @returns {typeof NotifyMeForm} NotifyMeForm widget\n */\nexport default function (AjaxForm) {\n class NotifyMeForm extends AjaxForm {\n prefs() {\n return {\n notifyEmail: 'dwfrm_notifyme_email',\n formButton: 'formButton',\n successMessage: 'successMessage',\n accessibilityAnnouncementMsg: '',\n ...super.prefs()\n };\n }\n\n /**\n * @description Handles server response\n * @emits \"alert.show\"\n * @param {object} data Server JSON response once form submitted\n * @returns {void}\n */\n onSubmitted(data) {\n if (data.success) {\n this.ref('formButton').hide();\n this.ref('successMessage')\n .setText(data.msg)\n .show();\n /**\n * @description Global event to show alert\n * @event \"alert.show\"\n */\n this.eventBus().emit('alert.show', {\n accessibilityAlert: this.prefs().accessibilityAnnouncementMsg\n });\n }\n\n if (!data.success) {\n if (data.fieldErrors) {\n Object.entries(data.fieldErrors).forEach(([name, errorMsg]) => {\n this.getById(name, formField => formField.setError(errorMsg));\n });\n }\n if (data.msg) {\n this.getById(this.prefs().notifyEmail, inputEmail => inputEmail.setError(data.msg));\n }\n }\n }\n }\n\n return NotifyMeForm;\n}\n"],"sourceRoot":""}