"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),s=require("react/jsx-runtime"),r=require("appsec-ui"),a=require("../store/useAuthStore.js"),c=require("../store/usePermissionsStore.js"),o=require("./AccessPanel.module.css.js"),n=require("../store/useEnvStore.js");exports.default=function(t){var u=t.ruleSetId,i=t.resourceId,d=t.moduleId,l=t.accessLevel,p=void 0===l?"scope":l,f=t.mode,m=void 0===f?"both":f;t.canManageAppAccess;var v=a.default(function(e){return e.user}),j=n.default(function(e){return e.rbacConfig}),g=n.default(function(e){return e.appsecRbacUrl}),P=n.default(function(e){return e.appsecBaseUrl}),_=null==v?void 0:v.accessToken,h=c.usePermissionsStore(function(e){return e.hasPermission}),x=i||u||void 0,A=Boolean(x),I="application"===p,b=I?"ilotj.scope.access.application":"ilotj.scope.access",q=A&&h("".concat(b,".user.add"),x),U=A&&h("".concat(b,".user.edit"),x),S=A&&h("".concat(b,".user.remove"),x),N=A&&h("".concat(b,".group.add"),x),y=A&&h("".concat(b,".group.edit"),x),E=A&&h("".concat(b,".group.remove"),x);if(!(x&&j&&g&&P))return s.jsx("div",e.__assign({className:o.default.accessPanel},{children:s.jsx("p",e.__assign({className:o.default.emptyState},{children:"Waiting for access configuration..."}))}));var G=I?j.applicationModuleId||d||j.moduleId:d||j.moduleId;return s.jsx("div",e.__assign({className:o.default.accessPanel},{children:s.jsx(r.RbacQueryProvider,{children:s.jsx(r.AppsecProvider,e.__assign({appId:j.applicationName,baseUrl:g,appsecUrl:P,mode:"manage",getAuthToken:function(){return null!=_?_:""}},{children:s.jsx(r.AccessListPanel,{resourceId:x,moduleId:G,mode:m,canAddUser:q,canEditUser:U,canDeleteUser:S,canAddGroup:N,canEditGroup:y,canDeleteGroup:E})}))})}))};
//# sourceMappingURL=AccessPanel.js.map
