"use strict";var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/asyncToGenerator"),n=require("@babel/runtime/regenerator"),u=require("react"),i=require("./utils.js"),c=require("../clients/jsonApi/index.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(e),s=a(r),f=a(t),p=a(n);function l(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function b(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?l(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function d(e){return h.apply(this,arguments)}function h(){return(h=f.default(p.default.mark((function e(r){return p.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,c.getPermissionCheck(r);case 3:return e.abrupt("return",e.sent);case 6:return e.prev=6,e.t0=e.catch(0),console.error(e.t0),e.abrupt("return",{active:!1});case 10:case"end":return e.stop()}}),e,null,[[0,6]])})))).apply(this,arguments)}module.exports=function(){var e=u.useState({}),r=s.default(e,2),t=r[0],n=r[1],c=u.useRef(new Set);function a(){return(a=f.default(p.default.mark((function e(r){var u,a;return p.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((u=r.filter((function(e){return!(e in t)&&!c.current.has(e)}))).length){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,Promise.all(u.map((function(e){return c.current.add(e),d(i.parsePermission(e))})));case 5:a=e.sent,n((function(e){var r=b({},e);return u.forEach((function(e,t){c.current.delete(e),r[e]=b({loading:!1},a[t])})),r}));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return window[Symbol.for("resetPermissionsCache")]=function(){return n({})},{permissions:t,fetchPermissions:function(e){return a.apply(this,arguments)}}};
//# sourceMappingURL=useProvidePermissions.js.map
