"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/regenerator"),r=require("react"),a=require("../utils.js"),s=require("../../types.js"),u=require("../../utils.js"),n=require("./sharedHooks.js"),i=require("./useSelectTemplate.js");require("../../../../utils/index.js");var c=require("../../../../utils/notificationToasts.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=l(e),p=l(t);exports.useCreateTemplate=function(){var e=n.useGet("get"),t=n.useGet("set"),l=i.useSelectTemplate();return r.useCallback(function(){var r=o.default(p.default.mark((function r(n){var i,o,f;return p.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=a.setBusy(t,0,s.Action.Create),r.prev=1,o=u.suggestName(n,a.getAllTemplates(e))||n,r.next=5,a.addTemplate(e,t,{name:o,settings:e().templateSettings||{},metadata:{}});case 5:return f=r.sent,r.next=8,l(f.id);case 8:c.showSuccessNotification('"'.concat(f.name,'" was created')),r.next=14;break;case 11:r.prev=11,r.t0=r.catch(1),console.error(r.t0);case 14:i();case 15:case"end":return r.stop()}}),r,null,[[1,11]])})));return function(e){return r.apply(this,arguments)}}(),[e,t,l])};
//# sourceMappingURL=useCreateTemplate.js.map
