"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/regenerator"),t=require("react"),s=require("../utils.js"),a=require("../../types.js"),n=require("../../utils.js"),u=require("./sharedHooks.js"),o=require("./useSelectTemplate.js");require("../../../../utils/index.js");var c=require("../../../../utils/notificationToasts.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=i(e),p=i(r);exports.useImportTemplate=function(){var e=u.useGet("get"),r=u.useGet("set"),i=o.useSelectTemplate();return t.useCallback(l.default(p.default.mark((function t(){var u,o,l,d;return p.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=s.setBusy(r,0,a.Action.Create),t.prev=1,t.next=4,n.loadTextFile({extensions:[".json"]});case 4:return o=t.sent,t.prev=5,l=n.parseTemplateImportData(o),t.next=9,s.addTemplate(e,r,l);case 9:return d=t.sent,t.next=12,i(d.id);case 12:c.showSuccessNotification('"'.concat(d.name,'" was created')),t.next=19;break;case 15:t.prev=15,t.t0=t.catch(5),c.showErrorNotification("An error occurred: ".concat((null===t.t0||void 0===t.t0?void 0:t.t0.message)||"Unknown error")),console.error(t.t0);case 19:t.next=23;break;case 21:t.prev=21,t.t1=t.catch(1);case 23:u();case 24:case"end":return t.stop()}}),t,null,[[1,21],[5,15]])}))),[e,r,i])};
//# sourceMappingURL=useImportTemplate.js.map
