"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/regenerator"),t=require("react"),n=require("../../types.js"),i=require("../../utils.js"),s=require("../utils.js"),u=require("./sharedHooks.js"),a=require("./useCloseFolderMenu.js");require("../../../../utils/index.js");var l=require("../../../../clients/jsonApi/index.js"),o=require("../../../../utils/notificationToasts.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(e),f=c(r);exports.useDeleteFolder=function(e){var r=u.useGet("get"),c=u.useGet("set"),p=a.useCloseFolderMenu(),m=t.useCallback(d.default(f.default.mark((function t(){var n,u,a;return f.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=11;break}return p(),n=r(),u=n.currentTemplateId,a=e.items.filter(i.isTemplate).map((function(e){return e.id})),c((function(e){return{loadedTemplates:e.loadedTemplates.filter((function(e){var r=e.id;return!a.includes(r)}))}})),t.next=7,Promise.all(a.map((function(e){return l.deleteAppSettingsTemplate(r().appKey,e)})));case 7:if(void 0===u||!a.includes(u)){t.next=10;break}return t.next=10,s.selectTemplateOnDeletion(r,c);case 10:o.showSuccessNotification('Folder "'.concat(null==e?void 0:e.name,'" has been successfully deleted.'));case 11:case"end":return t.stop()}}),t)}))),[p,e,r,c]);return u.useConfirmation(n.ConfirmationModalType.DeleteFolder,m,{confirmationTargetFolder:e})};
//# sourceMappingURL=useDeleteFolder.js.map
