import e from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/regenerator";import{useCallback as r}from"react";import{setBusy as s,getAllTemplates as o,addTemplate as n,findTemplate as a,ensureTemplateSettings as i}from"../utils.js";import{Action as m}from"../../types.js";import{suggestName as p,getMetadataForCopyOrExport as c}from"../../utils.js";import{useGet as u}from"./sharedHooks.js";import{useCloseTemplateMenu as f}from"./useCloseTemplateMenu.js";import{useSelectTemplate as l}from"./useSelectTemplate.js";import"../../../../utils/index.js";import{showSuccessNotification as j}from"../../../../utils/notificationToasts.js";var d=function(d){var v=u("set"),x=u("get"),b=f(),g=l();return r(e(t.mark((function e(){var r,u,f,l,h;return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(b(),!(r=a(x,d))){e.next=20;break}return e.next=5,i(x,v,r);case 5:return u=e.sent,f=s(v,r.id,m.SaveSettings),e.prev=7,l=p(u.name,o(x))||u.name,e.next=11,n(x,v,{name:l,settings:x().templateSettings||u.settings,metadata:c(u)});case 11:h=e.sent,j('"'.concat(u.name,'" template was copied!')),g(h.id),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(7),console.error(e.t0);case 19:f();case 20:case"end":return e.stop()}}),e,null,[[7,16]])}))),[b,x,v,g,d])};export{d as useCopyTemplate};
//# sourceMappingURL=useCopyTemplate.js.map
