@ws-ui/roles-editor 1.11.12-rc11 → 1.11.12-rc12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -110,5 +110,5 @@ Valid keys: `+JSON.stringify(Object.keys(k),null," "));var re=ue(q,te,j,G,H+"."
110
110
  `)&&(W="(?: "+W+")",ee=" "+ee,J++),D=new RegExp("^(?:"+W+")",k)),_&&(D=new RegExp("^"+W+"$(?!\\s)",k)),w&&(z=N.lastIndex),P=e(p,Q?D:N,ee),Q?P?(P.input=b(P.input,J),P[0]=b(P[0],J),P.index=N.lastIndex,N.lastIndex+=P[0].length):N.lastIndex=0:w&&P&&(N.lastIndex=N.global?P.index+P[0].length:z),_&&P&&P.length>1&&e(d,P[0],D,function(){for(K=1;K<arguments.length-2;K++)arguments[K]===void 0&&(P[K]=void 0)}),P&&U)for(P.groups=$=a(null),K=0;K<U.length;K++)Y=U[K],$[Y[0]]=P[Y[1]];return P}),ew=v,ew}var e2;function pF(){if(e2)return Kj;e2=1;var e=Fi(),t=J_();return e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t}),Kj}pF();var t2={},tw,r2;function hF(){if(r2)return tw;r2=1,pF();var e=zr(),t=xo(),r=J_(),n=_t(),i=Sr(),o=pl(),a=i("species"),s=RegExp.prototype;return tw=function(c,u,d,p){var v=i(c),h=!n(function(){var w={};return w[v]=function(){return 7},""[c](w)!==7}),x=h&&!n(function(){var w=!1,y=/a/;return c==="split"&&(y={},y.constructor={},y.constructor[a]=function(){return y},y.flags="",y[v]=/./[v]),y.exec=function(){return w=!0,null},y[v](""),!w});if(!h||!x||d){var m=/./[v],b=u(v,""[c],function(w,y,_,S,E){var I=y.exec;return I===r||I===s.exec?h&&!E?{done:!0,value:e(m,y,_,S)}:{done:!0,value:e(w,_,y,S)}:{done:!1}});t(String.prototype,c,b[0]),t(s,v,b[1])}p&&o(s[v],"sham",!0)},tw}var rw,n2;function vF(){if(n2)return rw;n2=1;var e=QB().charAt;return rw=function(t,r,n){return r+(n?e(t,r).length:1)},rw}var nw,i2;function yse(){if(i2)return nw;i2=1;var e=Wt(),t=_t(),r=e.RegExp,n=!t(function(){var i=!0;try{r(".","d")}catch{i=!1}var o={},a="",s=i?"dgimsy":"gimsy",c=function(v,h){Object.defineProperty(o,v,{get:function(){return a+=h,!0}})},u={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};i&&(u.hasIndices="d");for(var d in u)c(d,u[d]);var p=Object.getOwnPropertyDescriptor(r.prototype,"flags").get.call(o);return p!==s||a!==s});return nw={correct:n},nw}var iw,o2;function gF(){if(o2)return iw;o2=1;var e=zr(),t=gn(),r=Md(),n=yse(),i=fF(),o=RegExp.prototype;return iw=n.correct?function(a){return a.flags}:function(a){return!n.correct&&r(o,a)&&!t(a,"flags")?e(i,a):a.flags},iw}var ow,a2;function mF(){if(a2)return ow;a2=1;var e=zr(),t=mn(),r=Jt(),n=Bi(),i=J_(),o=TypeError;return ow=function(a,s){var c=a.exec;if(r(c)){var u=e(c,a,s);return u!==null&&t(u),u}if(n(a)==="RegExp")return e(i,a,s);throw new o("RegExp#exec called on incompatible receiver")},ow}var s2;function xse(){if(s2)return t2;s2=1;var e=zr(),t=bt(),r=hF(),n=mn(),i=sr(),o=U_(),a=wo(),s=yo(),c=fl(),u=vF(),d=gF(),p=mF(),v=t("".indexOf);return r("match",function(h,x,m){return[function(w){var y=s(this),_=i(w)?c(w,h):void 0;return _?e(_,w,y):new RegExp(w)[h](a(y))},function(b){var w=n(this),y=a(b),_=m(x,w,y);if(_.done)return _.value;var S=a(d(w));if(v(S,"g")===-1)return p(w,y);var E=v(S,"u")!==-1;w.lastIndex=0;for(var I=[],N=0,T;(T=p(w,y))!==null;){var A=a(T[0]);I[N]=A,A===""&&(w.lastIndex=u(y,o(w.lastIndex),E)),N++}return N===0?null:I}]}),t2}xse();var l2={},aw,c2;function wse(){if(c2)return aw;c2=1;var e=zB(),t=hi();return aw=function(r,n,i){return i.get&&e(i.get,n,{getter:!0}),i.set&&e(i.set,n,{setter:!0}),t.f(r,n,i)},aw}var u2;function _se(){if(u2)return l2;u2=1;var e=An(),t=V_().EXISTS,r=bt(),n=wse(),i=Function.prototype,o=r(i.toString),a=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,s=r(a.exec),c="name";return e&&!t&&n(i,c,{configurable:!0,get:function(){try{return s(a,o(this))[1]}catch{return""}}}),l2}_se();var d2={},sw,f2;function Ese(){if(f2)return sw;f2=1;var e=Pd(),t=Function.prototype,r=t.apply,n=t.call;return sw=typeof Reflect=="object"&&Reflect.apply||(e?n.bind(r):function(){return n.apply(r,arguments)}),sw}var lw,p2;function Sse(){if(p2)return lw;p2=1;var e=bt(),t=Ia(),r=Math.floor,n=e("".charAt),i=e("".replace),o=e("".slice),a=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,s=/\$([$&'`]|\d{1,2})/g;return lw=function(c,u,d,p,v,h){var x=d+c.length,m=p.length,b=s;return v!==void 0&&(v=t(v),b=a),i(h,b,function(w,y){var _;switch(n(y,0)){case"$":return"$";case"&":return c;case"`":return o(u,0,d);case"'":return o(u,x);case"<":_=v[o(y,1,-1)];break;default:var S=+y;if(S===0)return w;if(S>m){var E=r(S/10);return E===0?w:E<=m?p[E-1]===void 0?n(y,1):p[E-1]+n(y,1):w}_=p[S-1]}return _===void 0?"":_})},lw}var h2;function Ose(){if(h2)return d2;h2=1;var e=Ese(),t=zr(),r=bt(),n=hF(),i=_t(),o=mn(),a=Jt(),s=sr(),c=qd(),u=U_(),d=wo(),p=yo(),v=vF(),h=fl(),x=Sse(),m=gF(),b=mF(),w=Sr(),y=w("replace"),_=Math.max,S=Math.min,E=r([].concat),I=r([].push),N=r("".indexOf),T=r("".slice),A=function(z){return z===void 0?z:String(z)},B=(function(){return"a".replace(/./,"$0")==="$0"})(),L=(function(){return/./[y]?/./[y]("a","$0")==="":!1})(),D=!i(function(){var z=/./;return z.exec=function(){var P=[];return P.groups={a:"7"},P},"".replace(z,"$<a>")!=="7"});return n("replace",function(z,P,K){var $=L?"$":"$0";return[function(U,Q){var k=p(this),W=s(U)?h(U,y):void 0;return W?t(W,U,k,Q):t(P,d(k),U,Q)},function(Y,U){var Q=o(this),k=d(Y);if(typeof U=="string"&&N(U,$)===-1&&N(U,"$<")===-1){var W=K(P,Q,k,U);if(W.done)return W.value}var J=a(U);J||(U=d(U));var ee=d(m(Q)),j=N(ee,"g")!==-1,G;j&&(G=N(ee,"u")!==-1,Q.lastIndex=0);for(var H=[],q;q=b(Q,k),!(q===null||(I(H,q),!j));){var X=d(q[0]);X===""&&(Q.lastIndex=v(k,u(Q.lastIndex),G))}for(var ne="",te=0,ue=0;ue<H.length;ue++){q=H[ue];for(var re=d(q[0]),ge=_(S(c(q.index),k.length),0),de=[],xe,se=1;se<q.length;se++)I(de,A(q[se]));var le=q.groups;if(J){var we=E([re],de,ge,k);le!==void 0&&I(we,le),xe=d(e(U,void 0,we))}else xe=x(re,k,ge,de,le,U);ge>=te&&(ne+=T(k,te,ge)+xe,te=ge+re.length)}return ne+T(k,te)}]},!D||!B||L),d2}Ose();function Ti(e){return!e||!e.ownerDocument||!e.ownerDocument.defaultView?window:e.ownerDocument.defaultView}function uu(e){return!e||!e.ownerDocument?document:e.ownerDocument}var Ko=null,v2=null;dF&&window.addEventListener("resize",function(){v2!==window.devicePixelRatio&&(v2=window.devicePixelRatio,Ko=null)});function g2(e){if(Ko===null){var t=uu(e);if(typeof t>"u")return Ko=0,Ko;var r=t.body,n=t.createElement("div");n.classList.add("simplebar-hide-scrollbar"),r.appendChild(n);var i=n.getBoundingClientRect().right;r.removeChild(n),Ko=i}return Ko}var $u=(function(){function e(r,n){var i=this;this.onScroll=function(){var o=Ti(i.el);i.scrollXTicking||(o.requestAnimationFrame(i.scrollX),i.scrollXTicking=!0),i.scrollYTicking||(o.requestAnimationFrame(i.scrollY),i.scrollYTicking=!0)},this.scrollX=function(){i.axis.x.isOverflowing&&(i.showScrollbar("x"),i.positionScrollbar("x")),i.scrollXTicking=!1},this.scrollY=function(){i.axis.y.isOverflowing&&(i.showScrollbar("y"),i.positionScrollbar("y")),i.scrollYTicking=!1},this.onMouseEnter=function(){i.showScrollbar("x"),i.showScrollbar("y")},this.onMouseMove=function(o){i.mouseX=o.clientX,i.mouseY=o.clientY,(i.axis.x.isOverflowing||i.axis.x.forceVisible)&&i.onMouseMoveForAxis("x"),(i.axis.y.isOverflowing||i.axis.y.forceVisible)&&i.onMouseMoveForAxis("y")},this.onMouseLeave=function(){i.onMouseMove.cancel(),(i.axis.x.isOverflowing||i.axis.x.forceVisible)&&i.onMouseLeaveForAxis("x"),(i.axis.y.isOverflowing||i.axis.y.forceVisible)&&i.onMouseLeaveForAxis("y"),i.mouseX=-1,i.mouseY=-1},this.onWindowResize=function(){i.scrollbarWidth=i.getScrollbarWidth(),i.hideNativeScrollbar()},this.hideScrollbars=function(){i.axis.x.track.rect=i.axis.x.track.el.getBoundingClientRect(),i.axis.y.track.rect=i.axis.y.track.el.getBoundingClientRect(),i.isWithinBounds(i.axis.y.track.rect)||(i.axis.y.scrollbar.el.classList.remove(i.classNames.visible),i.axis.y.isVisible=!1),i.isWithinBounds(i.axis.x.track.rect)||(i.axis.x.scrollbar.el.classList.remove(i.classNames.visible),i.axis.x.isVisible=!1)},this.onPointerEvent=function(o){var a,s;i.axis.x.track.rect=i.axis.x.track.el.getBoundingClientRect(),i.axis.y.track.rect=i.axis.y.track.el.getBoundingClientRect(),(i.axis.x.isOverflowing||i.axis.x.forceVisible)&&(a=i.isWithinBounds(i.axis.x.track.rect)),(i.axis.y.isOverflowing||i.axis.y.forceVisible)&&(s=i.isWithinBounds(i.axis.y.track.rect)),(a||s)&&(o.preventDefault(),o.stopPropagation(),o.type==="mousedown"&&(a&&(i.axis.x.scrollbar.rect=i.axis.x.scrollbar.el.getBoundingClientRect(),i.isWithinBounds(i.axis.x.scrollbar.rect)?i.onDragStart(o,"x"):i.onTrackClick(o,"x")),s&&(i.axis.y.scrollbar.rect=i.axis.y.scrollbar.el.getBoundingClientRect(),i.isWithinBounds(i.axis.y.scrollbar.rect)?i.onDragStart(o,"y"):i.onTrackClick(o,"y"))))},this.drag=function(o){var a,s=i.axis[i.draggedAxis].track,c=s.rect[i.axis[i.draggedAxis].sizeAttr],u=i.axis[i.draggedAxis].scrollbar,d=i.contentWrapperEl[i.axis[i.draggedAxis].scrollSizeAttr],p=parseInt(i.elStyles[i.axis[i.draggedAxis].sizeAttr],10);o.preventDefault(),o.stopPropagation(),i.draggedAxis==="y"?a=o.pageY:a=o.pageX;var v=a-s.rect[i.axis[i.draggedAxis].offsetAttr]-i.axis[i.draggedAxis].dragOffset,h=v/(c-u.size),x=h*(d-p);i.draggedAxis==="x"&&(x=i.isRtl&&e.getRtlHelpers().isRtlScrollbarInverted?x-(c+u.size):x,x=i.isRtl&&e.getRtlHelpers().isRtlScrollingInverted?-x:x),i.contentWrapperEl[i.axis[i.draggedAxis].scrollOffsetAttr]=x},this.onEndDrag=function(o){var a=uu(i.el),s=Ti(i.el);o.preventDefault(),o.stopPropagation(),i.el.classList.remove(i.classNames.dragging),a.removeEventListener("mousemove",i.drag,!0),a.removeEventListener("mouseup",i.onEndDrag,!0),i.removePreventClickId=s.setTimeout(function(){a.removeEventListener("click",i.preventClick,!0),a.removeEventListener("dblclick",i.preventClick,!0),i.removePreventClickId=null})},this.preventClick=function(o){o.preventDefault(),o.stopPropagation()},this.el=r,this.minScrollbarWidth=20,this.options=Object.assign({},e.defaultOptions,n),this.classNames=Object.assign({},e.defaultOptions.classNames,this.options.classNames),this.axis={x:{scrollOffsetAttr:"scrollLeft",sizeAttr:"width",scrollSizeAttr:"scrollWidth",offsetSizeAttr:"offsetWidth",offsetAttr:"left",overflowAttr:"overflowX",dragOffset:0,isOverflowing:!0,isVisible:!1,forceVisible:!1,track:{},scrollbar:{}},y:{scrollOffsetAttr:"scrollTop",sizeAttr:"height",scrollSizeAttr:"scrollHeight",offsetSizeAttr:"offsetHeight",offsetAttr:"top",overflowAttr:"overflowY",dragOffset:0,isOverflowing:!0,isVisible:!1,forceVisible:!1,track:{},scrollbar:{}}},this.removePreventClickId=null,!e.instances.has(this.el)&&(this.recalculate=Rj(this.recalculate.bind(this),64),this.onMouseMove=Rj(this.onMouseMove.bind(this),64),this.hideScrollbars=Tj(this.hideScrollbars.bind(this),this.options.timeout),this.onWindowResize=Tj(this.onWindowResize.bind(this),64,{leading:!0}),e.getRtlHelpers=Fae(e.getRtlHelpers),this.init())}e.getRtlHelpers=function(){var n=document.createElement("div");n.innerHTML='<div class="hs-dummy-scrollbar-size"><div style="height: 200%; width: 200%; margin: 10px 0;"></div></div>';var i=n.firstElementChild;document.body.appendChild(i);var o=i.firstElementChild;i.scrollLeft=0;var a=e.getOffset(i),s=e.getOffset(o);i.scrollLeft=999;var c=e.getOffset(o);return{isRtlScrollingInverted:a.left!==s.left&&s.left-c.left!==0,isRtlScrollbarInverted:a.left!==s.left}},e.getOffset=function(n){var i=n.getBoundingClientRect(),o=uu(n),a=Ti(n);return{top:i.top+(a.pageYOffset||o.documentElement.scrollTop),left:i.left+(a.pageXOffset||o.documentElement.scrollLeft)}};var t=e.prototype;return t.init=function(){e.instances.set(this.el,this),dF&&(this.initDOM(),this.setAccessibilityAttributes(),this.scrollbarWidth=this.getScrollbarWidth(),this.recalculate(),this.initListeners())},t.initDOM=function(){var n=this;if(Array.prototype.filter.call(this.el.children,function(a){return a.classList.contains(n.classNames.wrapper)}).length)this.wrapperEl=this.el.querySelector("."+this.classNames.wrapper),this.contentWrapperEl=this.options.scrollableNode||this.el.querySelector("."+this.classNames.contentWrapper),this.contentEl=this.options.contentNode||this.el.querySelector("."+this.classNames.contentEl),this.offsetEl=this.el.querySelector("."+this.classNames.offset),this.maskEl=this.el.querySelector("."+this.classNames.mask),this.placeholderEl=this.findChild(this.wrapperEl,"."+this.classNames.placeholder),this.heightAutoObserverWrapperEl=this.el.querySelector("."+this.classNames.heightAutoObserverWrapperEl),this.heightAutoObserverEl=this.el.querySelector("."+this.classNames.heightAutoObserverEl),this.axis.x.track.el=this.findChild(this.el,"."+this.classNames.track+"."+this.classNames.horizontal),this.axis.y.track.el=this.findChild(this.el,"."+this.classNames.track+"."+this.classNames.vertical);else{for(this.wrapperEl=document.createElement("div"),this.contentWrapperEl=document.createElement("div"),this.offsetEl=document.createElement("div"),this.maskEl=document.createElement("div"),this.contentEl=document.createElement("div"),this.placeholderEl=document.createElement("div"),this.heightAutoObserverWrapperEl=document.createElement("div"),this.heightAutoObserverEl=document.createElement("div"),this.wrapperEl.classList.add(this.classNames.wrapper),this.contentWrapperEl.classList.add(this.classNames.contentWrapper),this.offsetEl.classList.add(this.classNames.offset),this.maskEl.classList.add(this.classNames.mask),this.contentEl.classList.add(this.classNames.contentEl),this.placeholderEl.classList.add(this.classNames.placeholder),this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl),this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);this.el.firstChild;)this.contentEl.appendChild(this.el.firstChild);this.contentWrapperEl.appendChild(this.contentEl),this.offsetEl.appendChild(this.contentWrapperEl),this.maskEl.appendChild(this.offsetEl),this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl),this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl),this.wrapperEl.appendChild(this.maskEl),this.wrapperEl.appendChild(this.placeholderEl),this.el.appendChild(this.wrapperEl)}if(!this.axis.x.track.el||!this.axis.y.track.el){var i=document.createElement("div"),o=document.createElement("div");i.classList.add(this.classNames.track),o.classList.add(this.classNames.scrollbar),i.appendChild(o),this.axis.x.track.el=i.cloneNode(!0),this.axis.x.track.el.classList.add(this.classNames.horizontal),this.axis.y.track.el=i.cloneNode(!0),this.axis.y.track.el.classList.add(this.classNames.vertical),this.el.appendChild(this.axis.x.track.el),this.el.appendChild(this.axis.y.track.el)}this.axis.x.scrollbar.el=this.axis.x.track.el.querySelector("."+this.classNames.scrollbar),this.axis.y.scrollbar.el=this.axis.y.track.el.querySelector("."+this.classNames.scrollbar),this.options.autoHide||(this.axis.x.scrollbar.el.classList.add(this.classNames.visible),this.axis.y.scrollbar.el.classList.add(this.classNames.visible)),this.el.setAttribute("data-simplebar","init")},t.setAccessibilityAttributes=function(){var n=this.options.ariaLabel||"scrollable content";this.contentWrapperEl.setAttribute("tabindex","0"),this.contentWrapperEl.setAttribute("role","region"),this.contentWrapperEl.setAttribute("aria-label",n)},t.initListeners=function(){var n=this,i=Ti(this.el);this.options.autoHide&&this.el.addEventListener("mouseenter",this.onMouseEnter),["mousedown","click","dblclick"].forEach(function(c){n.el.addEventListener(c,n.onPointerEvent,!0)}),["touchstart","touchend","touchmove"].forEach(function(c){n.el.addEventListener(c,n.onPointerEvent,{capture:!0,passive:!0})}),this.el.addEventListener("mousemove",this.onMouseMove),this.el.addEventListener("mouseleave",this.onMouseLeave),this.contentWrapperEl.addEventListener("scroll",this.onScroll),i.addEventListener("resize",this.onWindowResize);var o=!1,a=null,s=i.ResizeObserver||lse;this.resizeObserver=new s(function(){!o||a!==null||(a=i.requestAnimationFrame(function(){n.recalculate(),a=null}))}),this.resizeObserver.observe(this.el),this.resizeObserver.observe(this.contentEl),i.requestAnimationFrame(function(){o=!0}),this.mutationObserver=new i.MutationObserver(this.recalculate),this.mutationObserver.observe(this.contentEl,{childList:!0,subtree:!0,characterData:!0})},t.recalculate=function(){var n=Ti(this.el);this.elStyles=n.getComputedStyle(this.el),this.isRtl=this.elStyles.direction==="rtl";var i=this.heightAutoObserverEl.offsetHeight<=1,o=this.heightAutoObserverEl.offsetWidth<=1,a=this.contentEl.offsetWidth,s=this.contentWrapperEl.offsetWidth,c=this.elStyles.overflowX,u=this.elStyles.overflowY;this.contentEl.style.padding=this.elStyles.paddingTop+" "+this.elStyles.paddingRight+" "+this.elStyles.paddingBottom+" "+this.elStyles.paddingLeft,this.wrapperEl.style.margin="-"+this.elStyles.paddingTop+" -"+this.elStyles.paddingRight+" -"+this.elStyles.paddingBottom+" -"+this.elStyles.paddingLeft;var d=this.contentEl.scrollHeight,p=this.contentEl.scrollWidth;this.contentWrapperEl.style.height=i?"auto":"100%",this.placeholderEl.style.width=o?a+"px":"auto",this.placeholderEl.style.height=d+"px";var v=this.contentWrapperEl.offsetHeight;this.axis.x.isOverflowing=p>a,this.axis.y.isOverflowing=d>v,this.axis.x.isOverflowing=c==="hidden"?!1:this.axis.x.isOverflowing,this.axis.y.isOverflowing=u==="hidden"?!1:this.axis.y.isOverflowing,this.axis.x.forceVisible=this.options.forceVisible==="x"||this.options.forceVisible===!0,this.axis.y.forceVisible=this.options.forceVisible==="y"||this.options.forceVisible===!0,this.hideNativeScrollbar();var h=this.axis.x.isOverflowing?this.scrollbarWidth:0,x=this.axis.y.isOverflowing?this.scrollbarWidth:0;this.axis.x.isOverflowing=this.axis.x.isOverflowing&&p>s-x,this.axis.y.isOverflowing=this.axis.y.isOverflowing&&d>v-h,this.axis.x.scrollbar.size=this.getScrollbarSize("x"),this.axis.y.scrollbar.size=this.getScrollbarSize("y"),this.axis.x.scrollbar.el.style.width=this.axis.x.scrollbar.size+"px",this.axis.y.scrollbar.el.style.height=this.axis.y.scrollbar.size+"px",this.positionScrollbar("x"),this.positionScrollbar("y"),this.toggleTrackVisibility("x"),this.toggleTrackVisibility("y")},t.getScrollbarSize=function(n){if(n===void 0&&(n="y"),!this.axis[n].isOverflowing)return 0;var i=this.contentEl[this.axis[n].scrollSizeAttr],o=this.axis[n].track.el[this.axis[n].offsetSizeAttr],a,s=o/i;return a=Math.max(~~(s*o),this.options.scrollbarMinSize),this.options.scrollbarMaxSize&&(a=Math.min(a,this.options.scrollbarMaxSize)),a},t.positionScrollbar=function(n){if(n===void 0&&(n="y"),!!this.axis[n].isOverflowing){var i=this.contentWrapperEl[this.axis[n].scrollSizeAttr],o=this.axis[n].track.el[this.axis[n].offsetSizeAttr],a=parseInt(this.elStyles[this.axis[n].sizeAttr],10),s=this.axis[n].scrollbar,c=this.contentWrapperEl[this.axis[n].scrollOffsetAttr];c=n==="x"&&this.isRtl&&e.getRtlHelpers().isRtlScrollingInverted?-c:c;var u=c/(i-a),d=~~((o-s.size)*u);d=n==="x"&&this.isRtl&&e.getRtlHelpers().isRtlScrollbarInverted?d+(o-s.size):d,s.el.style.transform=n==="x"?"translate3d("+d+"px, 0, 0)":"translate3d(0, "+d+"px, 0)"}},t.toggleTrackVisibility=function(n){n===void 0&&(n="y");var i=this.axis[n].track.el,o=this.axis[n].scrollbar.el;this.axis[n].isOverflowing||this.axis[n].forceVisible?(i.style.visibility="visible",this.contentWrapperEl.style[this.axis[n].overflowAttr]="scroll"):(i.style.visibility="hidden",this.contentWrapperEl.style[this.axis[n].overflowAttr]="hidden"),this.axis[n].isOverflowing?o.style.display="block":o.style.display="none"},t.hideNativeScrollbar=function(){this.offsetEl.style[this.isRtl?"left":"right"]=this.axis.y.isOverflowing||this.axis.y.forceVisible?"-"+this.scrollbarWidth+"px":0,this.offsetEl.style.bottom=this.axis.x.isOverflowing||this.axis.x.forceVisible?"-"+this.scrollbarWidth+"px":0},t.onMouseMoveForAxis=function(n){n===void 0&&(n="y"),this.axis[n].track.rect=this.axis[n].track.el.getBoundingClientRect(),this.axis[n].scrollbar.rect=this.axis[n].scrollbar.el.getBoundingClientRect();var i=this.isWithinBounds(this.axis[n].scrollbar.rect);i?this.axis[n].scrollbar.el.classList.add(this.classNames.hover):this.axis[n].scrollbar.el.classList.remove(this.classNames.hover),this.isWithinBounds(this.axis[n].track.rect)?(this.showScrollbar(n),this.axis[n].track.el.classList.add(this.classNames.hover)):this.axis[n].track.el.classList.remove(this.classNames.hover)},t.onMouseLeaveForAxis=function(n){n===void 0&&(n="y"),this.axis[n].track.el.classList.remove(this.classNames.hover),this.axis[n].scrollbar.el.classList.remove(this.classNames.hover)},t.showScrollbar=function(n){n===void 0&&(n="y");var i=this.axis[n].scrollbar.el;this.axis[n].isVisible||(i.classList.add(this.classNames.visible),this.axis[n].isVisible=!0),this.options.autoHide&&this.hideScrollbars()},t.onDragStart=function(n,i){i===void 0&&(i="y");var o=uu(this.el),a=Ti(this.el),s=this.axis[i].scrollbar,c=i==="y"?n.pageY:n.pageX;this.axis[i].dragOffset=c-s.rect[this.axis[i].offsetAttr],this.draggedAxis=i,this.el.classList.add(this.classNames.dragging),o.addEventListener("mousemove",this.drag,!0),o.addEventListener("mouseup",this.onEndDrag,!0),this.removePreventClickId===null?(o.addEventListener("click",this.preventClick,!0),o.addEventListener("dblclick",this.preventClick,!0)):(a.clearTimeout(this.removePreventClickId),this.removePreventClickId=null)},t.onTrackClick=function(n,i){var o=this;if(i===void 0&&(i="y"),!!this.options.clickOnTrack){var a=Ti(this.el);this.axis[i].scrollbar.rect=this.axis[i].scrollbar.el.getBoundingClientRect();var s=this.axis[i].scrollbar,c=s.rect[this.axis[i].offsetAttr],u=parseInt(this.elStyles[this.axis[i].sizeAttr],10),d=this.contentWrapperEl[this.axis[i].scrollOffsetAttr],p=i==="y"?this.mouseY-c:this.mouseX-c,v=p<0?-1:1,h=v===-1?d-u:d+u,x=function m(){if(v===-1){if(d>h){var b;d-=o.options.clickOnTrackSpeed,o.contentWrapperEl.scrollTo((b={},b[o.axis[i].offsetAttr]=d,b)),a.requestAnimationFrame(m)}}else if(d<h){var w;d+=o.options.clickOnTrackSpeed,o.contentWrapperEl.scrollTo((w={},w[o.axis[i].offsetAttr]=d,w)),a.requestAnimationFrame(m)}};x()}},t.getContentElement=function(){return this.contentEl},t.getScrollElement=function(){return this.contentWrapperEl},t.getScrollbarWidth=function(){try{return getComputedStyle(this.contentWrapperEl,"::-webkit-scrollbar").display==="none"||"scrollbarWidth"in document.documentElement.style||"-ms-overflow-style"in document.documentElement.style?0:g2(this.el)}catch{return g2(this.el)}},t.removeListeners=function(){var n=this,i=Ti(this.el);this.options.autoHide&&this.el.removeEventListener("mouseenter",this.onMouseEnter),["mousedown","click","dblclick"].forEach(function(o){n.el.removeEventListener(o,n.onPointerEvent,!0)}),["touchstart","touchend","touchmove"].forEach(function(o){n.el.removeEventListener(o,n.onPointerEvent,{capture:!0,passive:!0})}),this.el.removeEventListener("mousemove",this.onMouseMove),this.el.removeEventListener("mouseleave",this.onMouseLeave),this.contentWrapperEl&&this.contentWrapperEl.removeEventListener("scroll",this.onScroll),i.removeEventListener("resize",this.onWindowResize),this.mutationObserver&&this.mutationObserver.disconnect(),this.resizeObserver&&this.resizeObserver.disconnect(),this.recalculate.cancel(),this.onMouseMove.cancel(),this.hideScrollbars.cancel(),this.onWindowResize.cancel()},t.unMount=function(){this.removeListeners(),e.instances.delete(this.el)},t.isWithinBounds=function(n){return this.mouseX>=n.left&&this.mouseX<=n.left+n.width&&this.mouseY>=n.top&&this.mouseY<=n.top+n.height},t.findChild=function(n,i){var o=n.matches||n.webkitMatchesSelector||n.mozMatchesSelector||n.msMatchesSelector;return Array.prototype.filter.call(n.children,function(a){return o.call(a,i)})[0]},e})();$u.defaultOptions={autoHide:!0,forceVisible:!1,clickOnTrack:!0,clickOnTrackSpeed:40,classNames:{contentEl:"simplebar-content",contentWrapper:"simplebar-content-wrapper",offset:"simplebar-offset",mask:"simplebar-mask",wrapper:"simplebar-wrapper",placeholder:"simplebar-placeholder",scrollbar:"simplebar-scrollbar",track:"simplebar-track",heightAutoObserverWrapperEl:"simplebar-height-auto-observer-wrapper",heightAutoObserverEl:"simplebar-height-auto-observer",visible:"simplebar-visible",horizontal:"simplebar-horizontal",vertical:"simplebar-vertical",hover:"simplebar-hover",dragging:"simplebar-dragging"},scrollbarMinSize:25,scrollbarMaxSize:0,timeout:1e3};$u.instances=new WeakMap;function m2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Gc(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?m2(Object(r),!0).forEach(function(n){Cse(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m2(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Cse(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Hu(){return Hu=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Hu.apply(this,arguments)}function Ise(e,t){if(e==null)return{};var r={},n=Object.keys(e),i,o;for(o=0;o<n.length;o++)i=n[o],!(t.indexOf(i)>=0)&&(r[i]=e[i]);return r}function Rse(e,t){if(e==null)return{};var r=Ise(e,t),n,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var Nse=["children","scrollableNodeProps","tag"],Tse=function(t){var r=Array.prototype.reduce.call(t,function(n,i){var o=i.name.match(/data-simplebar-(.+)/);if(o){var a=o[1].replace(/\W+(.)/g,function(s,c){return c.toUpperCase()});switch(i.value){case"true":n[a]=!0;break;case"false":n[a]=!1;break;case void 0:n[a]=!0;break;default:n[a]=i.value}}return n},{});return r},$d=O.forwardRef(function(e,t){var r=e.children,n=e.scrollableNodeProps,i=n===void 0?{}:n,o=e.tag,a=o===void 0?"div":o,s=Rse(e,Nse),c=a,u,d=O.useRef(),p=O.useRef(),v=O.useRef(),h={},x={},m=[];return Object.keys(s).forEach(function(b){Object.prototype.hasOwnProperty.call($u.defaultOptions,b)?h[b]=s[b]:b.match(/data-simplebar-(.+)/)&&b!=="data-simplebar-direction"?m.push({name:b,value:s[b]}):x[b]=s[b]}),m.length&&console.warn(`simplebar-react: this way of passing options is deprecated. Pass it like normal props instead:
111
111
  'data-simplebar-auto-hide="false"' —> 'autoHide="false"'
112
112
  `),O.useEffect(function(){return d=i.ref||d,p.current&&(u=new $u(p.current,Gc(Gc(Gc(Gc({},Tse(m)),h),d&&{scrollableNode:d.current}),v.current&&{contentNode:v.current})),typeof t=="function"?t(u):t&&(t.current=u)),function(){u.unMount(),u=null,typeof t=="function"&&t(null)}},[]),O.createElement(c,Hu({ref:p,"data-simplebar":!0},x),O.createElement("div",{className:"simplebar-wrapper"},O.createElement("div",{className:"simplebar-height-auto-observer-wrapper"},O.createElement("div",{className:"simplebar-height-auto-observer"})),O.createElement("div",{className:"simplebar-mask"},O.createElement("div",{className:"simplebar-offset"},typeof r=="function"?r({scrollableNodeRef:d,contentNodeRef:v}):O.createElement("div",Hu({},i,{className:"simplebar-content-wrapper".concat(i.className?" ".concat(i.className):"")}),O.createElement("div",{className:"simplebar-content"},r)))),O.createElement("div",{className:"simplebar-placeholder"})),O.createElement("div",{className:"simplebar-track simplebar-horizontal"},O.createElement("div",{className:"simplebar-scrollbar"})),O.createElement("div",{className:"simplebar-track simplebar-vertical"},O.createElement("div",{className:"simplebar-scrollbar"})))});$d.displayName="SimpleBar";$d.propTypes={children:hs.oneOfType([hs.node,hs.func]),scrollableNodeProps:hs.object,tag:hs.string};const bF=e=>{switch(e){case fe.EPermissionType.DATACLASS:return C.jsx(_e.FdTableHeader,{className:"h-6 w-6"});case fe.EPermissionType.SINGLETON:return C.jsx(_e.FdSingleton,{className:"h-6 w-6"});case fe.EPermissionType.DATASTORE:return C.jsx(_e.FdModel3,{className:"h-6 w-6"});case fe.EPermissionType.ATTRIBUTE:return C.jsx(_e.FdTableColumn,{className:"h-6 w-6"});case fe.EPermissionType.METHOD:return C.jsx(_e.FdCode,{className:"h-6 w-6"});case fe.EPermissionType.SINGLETON_METHOD:return C.jsx(_e.FdFunctionSingleton,{className:"h-6 w-6"});case fe.ESubPermissionType.ENTITY_SEL_METHOD:return C.jsx(_e.FdFunctionSelection,{className:"h-6 w-6"});case fe.ESubPermissionType.ENTITY_METHOD:return C.jsx(_e.FdFunctionEntity,{className:"h-6 w-6"});case fe.ESubPermissionType.DS_METHOD:return C.jsx(_e.FdFunctionDatastore,{className:"h-6 w-6"});case fe.ESubPermissionType.DATACLASS_METHOD:return C.jsx(_e.FdFunctionDataclass,{className:"h-6 w-6"});default:return C.jsx(_e.FdTableHeader,{className:"h-6 w-6"})}},b2=({children:e})=>C.jsx("div",{className:"h-full w-full",children:C.jsx("div",{className:"flex h-full w-full flex-1 items-center justify-center",children:C.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 py-4 text-inactive-text",children:[C.jsx(_e.FdInfoBold,{className:"h-10 w-10"}),C.jsx("div",{className:"text-center text-sm",children:e})]})})}),Uo=({permissions:e,label:t,onToggle:r,onSelect:n,promoted:i,showIncluded:o,privileges:a,exists:s})=>{const c=e.find(u=>u.name===t);return c?C.jsxs("div",{className:"relative mx-auto flex w-fit items-center",children:[C.jsx(or,{value:c.checked||c.from.length===0||t==="promote"?c.checked:o&&c.from.length>0?null:!1,onChange:()=>r&&r(c),isInvalid:s===!1}),C.jsxs("div",{className:"absolute left-full translate-x-1/4 top-1/2 -translate-y-1/2 flex cursor-pointer items-center space-x-1",children:[t!=="promote"&&(c.checked&&(c.info||c.from.length>0)||!c.checked&&c.from.length>0)&&C.jsx(C.Fragment,{children:C.jsx(Kr,{container:xr(),delay:100,label:C.jsxs("div",{className:"max-w-xs h-fit flex flex-col gap-y-3 p-1.5 text-sm font-semibold",children:[c.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:c.from.map(u=>C.jsx("li",{className:"cursor-pointer list-disc font-bold hover:underline",onClick:()=>n(a[u].id),children:a[u].privilege}))})]})]}):null,c.info&&C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdInfoCircle,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"})," ",C.jsx("span",{className:"flex-1 min-w-0 break-words whitespace-normal text-left",children:c.info})]})]}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4 "})})}),(c.checked||c.from.length>0)&&["execute"].includes(t)&&!!(i!=null&&i.length)&&C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:C.jsxs("div",{className:"flex items-start text-s",children:[C.jsx(_e.FdInfoCircle,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{children:[C.jsx("span",{className:"mr-1",children:"Function is promoted with: "}),i==null?void 0:i.map(u=>C.jsx("li",{className:"cursor-pointer list-disc font-bold hover:underline",onClick:()=>n(a[u].id),children:a[u].privilege}))]})]})}),children:C.jsx(_e.FdCrown,{className:"h-3 w-3 "})})]})]}):null},Pse=({privilegeId:e,privileges:t})=>{const r=pr(),n=r.getCatalogMethods(),i=r.getDataclasses(),o=r.getSingletons(),a=t[e],[s,c]=O.useState([]),[u,d]=O.useState("");O.useEffect(()=>{d("")},[e]),O.useEffect(()=>{const h=a.resources.map(({resource:m,type:b,subType:w})=>({type:b,applyTo:m,subType:w})),x=k_(u.toLowerCase(),n,Object.values(i),Object.values(o));c(x.filter(({applyTo:m,type:b,subType:w})=>!lo.find(h,{applyTo:m,type:b,subType:w})))},[u,a.resources]);const[p,v]=O.useState(!1);return C.jsx(xC.Root,{className:"w-56",onInputChange:h=>d(h||""),onOpenChange:v,isOpen:p,isSearchable:!0,options:s,getOptionLabel:h=>h?h.applyTo:"",getOptionValue:h=>h?h.applyTo:"",value:null,onChange:h=>{if(!h)return;const x=fe.addPermission(e,h,t);r.actions.updatePrivileges(x),d("")},children:C.jsx(xC.Field,{formatOptionLabel:h=>C.jsxs("div",{className:"flex items-center space-x-2",children:[bF(h.type),C.jsx("span",{children:h.applyTo})]}),placeholder:"Create a permission"})})};function kse(e){const t=["datastore","singleton","dataclass","attribute","dsMethod","dataclassMethod","entityMethod","entityselMethod","singletonMethod"],r=e.reduce((n,i)=>{const[o]=i.resource.split("."),a=n.find(s=>s.prefix===o.toLowerCase());return a?(a.resources.push(i),n):[...n,{prefix:o.toLowerCase(),type:i.type,resources:[i]}]},[]);return r.sort((n,i)=>n.prefix==="ds"?-1:i.prefix==="ds"||n.prefix>i.prefix?1:-1),r.map(n=>({...n,resources:n.resources.sort((i,o)=>{const a=t.indexOf(i.type),s=t.indexOf(o.type);return a!==s?a-s:i.resource.toLowerCase()>o.resource.toLowerCase()?1:-1})})).reduce((n,i)=>[...n,...i.resources],[])}const Ase=({selectedPrivilege:e,onSelect:t,showIncluded:r,privileges:n})=>{const[i,o]=O.useState(null),[a,s]=O.useState(null),{styles:c,attributes:u}=rd(i,a,{modifiers:[{name:"offset",options:{offset:[0,10]}}]}),d=pr(),[p,v]=O.useState([]),[h,x]=O.useState(""),{id:m}=e,b=O.useMemo(()=>fe.getInheritedResources(m,n),[m,n[m].includes,n[m].resources]),w=O.useMemo(()=>fe.getPromotions(m,n),[n[m]]);function y(D){v(z=>z.some(P=>D.includes(P))?z.filter(P=>!D.includes(P)):[...z,...D])}const _=async D=>{const{confirmed:z}=await d.actions.openModal({title:"Delete Privilege",type:fe.ModalType.CONFIRM,color:fe.ModalColor.DANGER,message:"Are you sure you want to remove this Privilege?",icon:"FdWarningDanger"});if(z){const P=fe.removePermission(e.id,D,n);d.actions.updatePrivileges(P)}},S=async()=>{const{confirmed:D}=await d.actions.openModal({title:"Reset Permissions",type:fe.ModalType.CONFIRM,color:fe.ModalColor.DANGER,message:"Are you sure you want to reset permissions for this Privilege?",icon:"FdWarningDanger"});if(D){const z=fe.resetResources(e.id,n);d.actions.updatePrivileges(z)}},I=b.filter(D=>p.length===0?!0:p.includes(D.type)).filter(({resource:D})=>h?new RegExp(lo.escapeRegExp(h),"i").test(D):!0),N=kse(I),T=N.filter(D=>{const z=D.permissions.every(P=>!P.checked)&&D.permissions.some(P=>P.from.length>0);return r||!z}),A=(D,z)=>{const P=fe.togglePermission(e.id,D,z,n);d.actions.updatePrivileges(P)},B=O.useMemo(()=>T.some(D=>D.exists===!1),[T]),L=async()=>{const{confirmed:D}=await d.actions.openModal({title:"Delete Privilege",type:fe.ModalType.CONFIRM,color:fe.ModalColor.DANGER,message:"Are you sure you want to remove these permissions?",views:{tips:[{type:"warning",message:"This action will remove all permissions that don't exist in the catalog for all privileges"}]},icon:"FdWarningDanger"}),z=Object.entries(n).map(([P,K])=>{const $=K.resources.filter(Y=>!Y.exists);return{[P]:$.map(Y=>({applyTo:Y.resource,type:Y.type}))}}).reduce((P,K)=>({...P,...K}),{});if(D){const P=fe.removeMultiplePermissions(z,n);d.actions.updatePrivileges(P)}};return C.jsxs($d,{className:"z-20 h-full flex-1 overflow-auto p-[15px] pt-0",style:{maxHeight:"calc(100vh - 5.5rem - 85px - 20px)"},children:[C.jsxs("table",{className:"relative h-full w-full border-collapse",children:[C.jsx("thead",{className:"sticky top-0 z-20 bg-panel-1",children:C.jsxs("tr",{className:"border-b border-grey-100",children:[C.jsx("td",{className:"py-2",children:C.jsxs("div",{className:"flex items-center space-x-2",children:[C.jsx("div",{className:"relative w-56",children:C.jsx(wt.Root,{children:C.jsxs(wt.Group,{children:[C.jsx(wt.Icon,{children:C.jsx(_e.FdSearch,{})}),C.jsx(wt.Field,{type:"text",placeholder:"Search available permissions",value:h,onChange:D=>{x(D.target.value)}}),C.jsx(un.Popover,{className:"flex items-center",children:({open:D})=>C.jsxs(C.Fragment,{children:[C.jsx(un.Popover.Button,{ref:o,children:C.jsx(wt.Icon,{isAction:!0,children:C.jsx(_e.FdAdjust,{})})}),D&&C.jsx(Td,{children:C.jsx(un.Popover.Panel,{ref:s,style:c.popper,...u.popper,className:"z-50",static:!0,children:C.jsxs(dr,{depth:3,borderType:"light",className:"rounded-md border px-4 py-2.5",children:[C.jsx("h5",{className:"mb-2 text-sm",children:"Filter"}),C.jsxs("div",{className:"space-y-2 text-s",children:[C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:p.includes("datastore"),onChange:()=>{y(["datastore"])},label:"Datastore",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:p.includes("dataclass"),onChange:()=>{y(["dataclass"])},label:"Dataclass",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:p.includes("singleton"),onChange:()=>{y(["singleton"])},label:"Singleton",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:p.some(z=>["method","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"].includes(z)),onChange:()=>{y(["method","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"])},label:"Functions",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:p.includes("attribute"),onChange:()=>{y(["attribute"])},label:"Attribute",size:"sm"})})]})]})})})]})})]})})}),C.jsx(Pse,{privilegeId:m,privileges:n}),C.jsx("div",{children:C.jsx(Kr,{label:`Resetting the privilege will remove all configured\r
113
- ressources`,container:xr(),children:C.jsx(Zt,{color:"white",variant:"ghost",onClick:S,children:C.jsx(_e.FdReload,{})})})}),C.jsx(Kr,{icon:C.jsx(_e.FdBulb,{}),label:"Delete all the non existing resources from privileges",container:xr(),children:C.jsx(Zt,{color:"white",variant:"ghost",onClick:L,disabled:!B,children:C.jsx(_e.FdClean,{className:"h-4 w-4"})})})]})}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Read"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Create"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Update"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Delete"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Execute"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Promote"})]})}),T.length?C.jsx("tbody",{children:T.map((D,z)=>{const P=D.permissions.some(K=>K.from.length>0);return C.jsxs("tr",{className:Yr("group even:bg-white/5 hover:bg-input-bg",{"opacity-60":D.exists===!1}),children:[C.jsxs("td",{className:Yr("group flex items-center gap-3 py-2 text-xs group-hover:rounded-l group-hover:bg-input-bg ",D.exists===!1?"text-negative-text":""),children:[bF(D.type),D.resource,C.jsx(Kr,{label:"Remove Permission",container:xr(),children:C.jsx(Zt,{color:"white",variant:"ghost",disabled:P,onClick:()=>{P?fe.toastSubject.next({kind:"info",markdown:!0,message:`<div className="flex gap-x-3"><h3 className="font-bold">Info:</h3><p className="font-normal">Inherited permissions can't be removed</p></div>`,customIcon:_e.FdInfoBold}):_({applyTo:D.resource,type:D.type})},className:"opacity-0 group-hover:opacity-100",children:C.jsx(_e.FdPlus,{className:"h-4 w-4 rotate-45 transform"})})})]}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"read",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"create",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"update",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"drop",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:C.jsx(Uo,{promoted:w[D.resource],permissions:D.permissions,showIncluded:r,label:"execute",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:rounded-r group-hover:bg-input-bg",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"promote",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})})]},z)})}):null]}),!N.length&&h?C.jsx(b2,{children:"The Permission you're looking for can't be found "}):null,!N.length&&!h?C.jsxs(b2,{children:["This Privilege has no Permissions configured yet ",C.jsx("br",{}),'Add a new permission by using the "Create a permission" input above']}):null]})},Mse=({onCreate:e})=>{const t=pr(),r=t.getPrivileges(),[n,i]=O.useState(null),[o,a]=O.useState(null),[s,c]=O.useState(""),[u,d]=O.useState(null),{styles:p,attributes:v}=rd(n,o,{modifiers:[{name:"offset",options:{offset:[-10,10]}}],placement:"right-start"});O.useEffect(()=>{c(""),d(null)},[o]);const h=x=>{d(null);try{const m=fe.createPrivilege(s,r),b=Object.values(m).find(w=>w.privilege===s);t.actions.updatePrivileges(m),b&&e(b),setTimeout(()=>{x()},0)}catch(m){d(m.message)}};return C.jsx(un.Popover,{children:({open:x,close:m})=>C.jsxs(C.Fragment,{children:[C.jsx(un.Popover.Button,{className:"rounded","data-cy":"New-priv-btn",ref:i,children:C.jsx(Zt,{variant:"ghost",color:"white",children:C.jsx(_e.FdPlus,{className:"h-4 w-4"})})}),x&&C.jsx(Td,{children:C.jsx(un.Popover.Panel,{ref:a,style:p.popper,...v.popper,"data-cy":"New-priv-pop-up",className:"z-50",static:!0,children:C.jsxs(dr,{className:"min-w-[256px] border rounded px-4 py-2 text-xs shadow-md",depth:3,borderType:"light",children:[C.jsx("h5",{className:"mb-2 text-xs font-semibold",children:"Create New Privilege"}),C.jsx("div",{className:"mt-2",children:C.jsxs("label",{className:"flex items-center space-x-4",children:[C.jsx("span",{children:"Name"}),C.jsxs(wt.Root,{className:"w-full",color:u?"negative":"primary",children:[C.jsx(wt.Group,{children:C.jsx(wt.Field,{autoFocus:!0,value:s,onChange:b=>c(b.target.value),onKeyDown:b=>{b.key==="Enter"&&h(m)},type:"text"})}),u&&C.jsx(wt.Message,{children:u})]})]})}),C.jsxs("div",{className:"mt-4 flex items-center justify-center space-x-2",children:[C.jsx(Zt,{onClick:()=>{h(m)},children:"Create"}),C.jsx(Zt,{color:"white",variant:"outline",onClick:()=>m(),children:"Cancel"})]})]})})})]})})},Dse=()=>{const e=pr(),t=e.getCatalog(),r=e.getPrivileges(),n=O.useMemo(()=>{if(t===null)return r;const u=fB(r,Object.values((t==null?void 0:t.dataClasses)??{}));return pB(u,t)},[r,t]),[i,o]=O.useState(null),a=O.useMemo(()=>Object.keys(n),[n]);O.useEffect(()=>{i&&n[i.id]||!a.length||o(n[a[0]])},[n]),O.useEffect(()=>{a.length<2&&c(!0)},[a.length]);const[s,c]=O.useState(!0);return C.jsxs("div",{className:"flex flex-1 h-full",children:[C.jsxs(dr,{depth:1,className:"flex h-full w-[356px] flex-col",children:[C.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between px-3.5 py-[10px]",children:[C.jsxs("div",{className:"flex items-center space-x-1",children:[C.jsx("span",{children:C.jsx(_e.FdGroup,{className:"h-[14px] w-[14px]"})}),C.jsx("span",{className:"text-[11px] font-semibold",children:"Privileges"})]}),C.jsx(Mse,{onCreate:u=>{o(u)}})]}),C.jsx(Moe,{privileges:n,selectedPrivilege:i,selectPrivilege:u=>{o(u)}})]}),i&&n[i.id]?C.jsxs(dr,{depth:1,className:"privileges-container relative flex flex-1 flex-col overflow-x-auto border-l-[0.5px]",children:[C.jsxs("div",{className:"mb-1 flex h-full w-full flex-col items-stretch",children:[i.privilege!=="guest"?C.jsx(koe,{privileges:n,selectedPrivilege:i,onSelect:u=>o(r[u]),setShowIncluded:c,showIncluded:s}):null,C.jsx(Ase,{privileges:n,selectedPrivilege:i,onSelect:u=>o(r[u]),showIncluded:s})]}),C.jsx(jse,{privileges:n,selectedPrivilege:i,setSelectedPrivilege:o})]}):C.jsx(ZL,{tab:"Privilege"})]})},jse=({privileges:e,selectedPrivilege:t,setSelectedPrivilege:r})=>{const[n,i]=O.useState(!1);return C.jsx(fe.Panel,{path:fe.ROLES_TAB_PATH,isOpen:n,onOpen:()=>i(!0),onClose:()=>i(!1),children:C.jsx("div",{className:"h-full w-full px-3 pb-3",children:C.jsx(dr,{depth:2,className:"h-full w-full rounded",children:C.jsx($ie,{dict:e,data:fe.getGraphData(t.id,e),onSelect:o=>r(e[o])})})})})},qse=({role:e})=>{var E;const t=pr(),[r,n]=O.useState(e),[i,o]=O.useState(e.role),[a,s]=O.useState(null),c=t.getPrivileges(),u=((E=r.privileges)==null?void 0:E.filter(I=>c[I]&&c[I].privilege!=="guest").length)||0,d=t.getRoles(),{selectedRole:p,selectRole:v}=Y1(),[h,x]=O.useState(!1),m=fe.useOutsideClick(()=>{h&&w()});fe.useDidMountEffect(()=>{i!==e.role&&o(e.role)},[e.role]),O.useEffect(()=>{e.role||x(!0)},[]),O.useEffect(()=>{n(e)},[e]);const b=()=>{s(null),x(!0)},w=()=>{s(null),e.role&&e.role===i&&x(!1);try{const I=fe.saveRole({...r,role:i},d);t.actions.updateRoles(I),x(!1)}catch(I){s(I.message)}},y=async I=>{I.stopPropagation();const{confirmed:N}=await t.actions.openModal({title:"Delete Role",type:fe.ModalType.CONFIRM,color:fe.ModalColor.DANGER,message:"Are you sure you want to remove this Role?",icon:"FdWarningDanger"});N&&_()},_=()=>{const I=fe.removeRole(r.id,d),N=Object.keys(I);if(p!==r.id){t.actions.updateRoles(I);return}if(N.length===0)v(null);else{const T=Object.keys(d),A=T.indexOf(r.id),B=Math.max(0,A-1),L=T[B];A===0?v(N[0]):I[L]?v(L):v(N[0])}t.actions.updateRoles(I)},S=(I=null)=>{if(I&&I.stopPropagation(),!e.role){_();return}x(!1),o(e.role)};return C.jsx(C.Fragment,{children:C.jsxs(dr,{depth:4,borderType:p===r.id?"primary":p!==r.id?"light":"default",className:Yr("rounded border p-2"),role:"button","data-cy":"privilegeCard",onClick:()=>{v(r.id)},ref:m,children:[C.jsx("div",{className:"flex items-center justify-between",children:C.jsxs("div",{className:"flex flex-1 items-center",children:[C.jsx("span",{className:"mr-4",children:C.jsx(_e.FdGroup,{className:"h-6 w-6"})}),h?C.jsxs(wt.Root,{color:a?"negative":"primary",className:"flex-1 mr-2",children:[C.jsx(wt.Group,{children:C.jsx(wt.Field,{type:"text",value:i,onChange:({target:{value:I}})=>{o(I)},onKeyDown:I=>{I.key==="Enter"&&w(),I.key==="Escape"&&S()},onBlur:()=>S(),placeholder:"role",autoComplete:"off",autoFocus:!0})}),a&&C.jsx(wt.Message,{children:a})]}):C.jsx("span",{className:"inline-block grow overflow-hidden truncate whitespace-nowrap text-xs font-bold",title:i,children:r.role}),C.jsx("div",{className:Yr("justify-between ml-auto flex w-fit items-center gap-x-2"),children:h?C.jsxs(C.Fragment,{children:[C.jsx(Zt,{color:"white",variant:"ghost",onClick:w,children:C.jsx(_e.FdSave,{className:"h-4 w-4"})}),C.jsx(Zt,{color:"white",variant:"ghost",onClick:S,children:C.jsx(_e.FdClose,{className:"h-4 w-4"})})]}):C.jsxs(C.Fragment,{children:[C.jsx(Zt,{color:"white",variant:"ghost",onClick:b,children:C.jsx(_e.FdPen,{className:"h-4 w-4"})}),C.jsx(Zt,{color:"white",variant:"ghost",onClick:I=>y(I),children:C.jsx(_e.FdTrash,{className:"h-4 w-4"})})]})})]})}),C.jsxs("span",{className:Yr("ml-[43px] py-1 text-xs"),children:[u," Privilege",u>1?"s":""]})]})})},yF=(e,t)=>e?t[e]:null,y2=(e,t,r)=>{const n=yF(e,r);return n?Object.values(r).reduce((i,o)=>o.id===e?n.privileges.includes(t)?{...i,[n.id]:{...n,privileges:n.privileges.filter(a=>a!==t)}}:{...i,[n.id]:{...n,privileges:[...n.privileges,t]}}:{...i,[o.id]:o},{}):r},Lse=()=>{const e=pr(),t=e.getPrivileges(),r=e.getRoles(),{selectedRole:n}=Y1(),i=yF(n,r),o=(a,s)=>s&&s.privileges.includes(a.id);return C.jsxs(dr,{depth:1,className:"w-full border-b p-4 ",children:[C.jsx("div",{className:"mb-4 flex items-center gap-x-5",children:C.jsx("h4",{className:"text-[13px] font-semibold ",children:"Privileges"})}),C.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[C.jsx(Zc,{"data-cy":"item=>Permisions",className:"italic opacity-90",children:"guest"}),Object.values(t).filter(a=>o(a,i)&&a.privilege!=="guest").map((a,s)=>C.jsxs(Zc,{"data-cy":"item=>Permisions",color:"primary",onClick:()=>{const c=y2(i.id,a.id,r);e.actions.updateRoles(c)},children:[a.privilege,C.jsx(_e.FdPlus,{className:"rotate-45 transform"})]},s)),Object.values(t).filter(a=>!o(a,i)&&a.privilege!=="guest").map((a,s)=>C.jsxs(Zc,{"data-cy":"item=>Permisions",color:"dark",onClick:()=>{const c=y2(i.id,a.id,r);e.actions.updateRoles(c)},children:[a.privilege,C.jsx(_e.FdPlus,{})]},s))]})]})},zse=({children:e})=>C.jsx("div",{className:"h-full w-full",children:C.jsx("div",{className:"flex h-full w-full flex-1 items-center justify-center",children:C.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 py-4 text-inactive-text",children:[C.jsx(_e.FdInfoBold,{className:"absolute -right-full h-10 w-10 translate-x-1"}),C.jsx("div",{className:"text-center text-sm",children:e})]})})}),Hw=(e,t,r,n=!1)=>{const i=e.applyTo,o=e.type===fe.EPermissionType.DATACLASS?"ds":i.split(".")[0],a={...t,...r},s=()=>({value:!n,inherited:!1,from:[],explicitly:!1}),c={read:s(),create:s(),update:s(),drop:s(),execute:s(),promote:s()},u=p=>{p.forEach(v=>{a[v]&&(a[v].resources.forEach(h=>{if(h.resource===i||h.resource===o){const x=Hw(e,t,{[v]:a[v]},n);Object.values(h.permissions).forEach(m=>{c[m.name].explicitly||(!c[m.name].from.includes(a[v].privilege)&&m.checked&&c[m.name].from.push(a[v].privilege),c[m.name].inherited=c[m.name].inherited||x[m.name].value||x[m.name].inherited)})}}),a[v].includes.length>0&&u(a[v].includes))})};if(Object.values(r).forEach(p=>{p.resources.forEach(v=>{v.resource===i&&Object.values(v.permissions).forEach(h=>{h.checked&&(c[h.name].explicitly=!0,n&&(c[h.name].value=!0))})}),(p.includes.length>0||p.privilege==="guest")&&u(p.includes)}),Object.values(t).forEach(p=>{p.resources.forEach(v=>{v.resource===i&&(p.privilege==="guest"?Object.values(v.permissions).forEach(h=>{h.checked&&(c[h.name].explicitly=!0,n&&(c[h.name].value=!0))}):Object.values(v.permissions).forEach(h=>{!c[h.name].explicitly&&h.checked&&(n?c[h.name].value=!0:c[h.name].value=!1)}))})}),(n?Object.entries(c).some(([p,v])=>p!=="promote"&&!v.value&&!v.explicitly):Object.entries(c).some(([p,v])=>p!=="promote"&&v.value&&!v.explicitly))&&![fe.EPermissionType.DATASTORE,fe.EPermissionType.SINGLETON].includes(e.type)){const p={applyTo:o,type:e.type===fe.EPermissionType.DATACLASS?fe.EPermissionType.DATASTORE:e.type===fe.EPermissionType.SINGLETON_METHOD?fe.EPermissionType.SINGLETON:fe.EPermissionType.DATACLASS},v=Hw(p,t,r,n),h=x=>{let m=c[x].value;return n?!c[x].value&&!c[x].explicitly&&(m=v[x].value):c[x].value&&!c[x].explicitly&&(m=v[x].value),{value:m,inherited:c[x].inherited||v[x].inherited,from:c[x].from.length>0?c[x].from:v[x].from,explicitly:c[x].explicitly}};return{read:h("read"),create:h("create"),update:h("update"),drop:h("drop"),execute:h("execute"),promote:h("promote")}}return{read:c.read,create:c.create,update:c.update,drop:c.drop,execute:c.execute,promote:c.promote}},Bse=e=>{switch(e){case"dataclass":return C.jsx(_e.FdTableHeader,{className:"h-6 w-6"});case"singleton":return C.jsx(_e.FdSingleton,{className:"h-6 w-6"});case"datastore":return C.jsx(_e.FdModel3,{className:"h-6 w-6"});case"attribute":return C.jsx(_e.FdTableColumn,{className:"h-6 w-6"});case"method":return C.jsx(_e.FdCode,{className:"h-6 w-6"});case"singletonMethod":return C.jsx(_e.FdFunctionSingleton,{className:"h-6 w-6"});case"entityselMethod":return C.jsx(_e.FdFunctionSelection,{className:"h-6 w-6"});case"entityMethod":return C.jsx(_e.FdFunctionEntity,{className:"h-6 w-6"});case"dsMethod":return C.jsx(_e.FdFunctionDatastore,{className:"h-6 w-6"});case"dataclassMethod":return C.jsx(_e.FdFunctionDataclass,{className:"h-6 w-6"});default:return C.jsx(_e.FdTableHeader,{className:"h-6 w-6"})}},oa=({privileges:e,permission:t,hasChild:r,depth:n,isChild:i=!1,className:o,inSearch:a,toggleCollapse:s,collapsed:c,isRestrictedByDefault:u,toastMessageCallback:d})=>{const[p,v]=t.applyTo.split("."),h=O.useMemo(()=>Hw(t,e.otherPrivs,e.rolePrivs,u),[e,t,u]);return C.jsxs("tr",{className:Yr("group even:bg-white/5 hover:bg-input-bg",o),children:[C.jsxs("td",{className:Yr("flex h-full w-full items-stretch gap-3 p-0 text-xs group-hover:rounded-l group-hover:bg-input-bg",{"px-1":a}),children:[Array(n).fill("").map((x,m)=>C.jsx("div",{className:Yr("ml-1.5 mr-1 w-[2px] bg-grey-100",{"mr-0.5":i})},m)),C.jsxs("div",{className:"flex items-center gap-3 py-2",children:[r&&C.jsx("button",{onClick:s,className:"w-3",children:c?C.jsx(_e.FdRight,{className:"inline h-4 w-4"}):C.jsx(_e.FdDown,{className:"inline h-4 w-4"})}),Bse(t.type),a?t.applyTo:v||p]})]}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[fe.EPermissionType.ATTRIBUTE,fe.EPermissionType.DATASTORE,fe.EPermissionType.DATACLASS].includes(t.type)&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.read.value||h.read.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.read.value&&h.read.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.read.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.read.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[fe.EPermissionType.ATTRIBUTE,fe.EPermissionType.DATASTORE,fe.EPermissionType.DATACLASS].includes(t.type)&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.create.value||h.create.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.create.value&&h.create.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.read.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.read.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[fe.EPermissionType.ATTRIBUTE,fe.EPermissionType.DATASTORE,fe.EPermissionType.DATACLASS].includes(t.type)&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.update.value||h.update.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.update.value&&h.update.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.update.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.update.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[fe.EPermissionType.ATTRIBUTE,fe.EPermissionType.DATASTORE,fe.EPermissionType.DATACLASS].includes(t.type)&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.drop.value||h.drop.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.drop.value&&h.drop.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.drop.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.drop.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})}),C.jsx("td",{className:"py-2 text-center group-hover:rounded-r group-hover:bg-input-bg",children:t.type!=="attribute"&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.execute.value||h.execute.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.execute.value&&h.execute.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.execute.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.execute.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})})]})},x2=({depth:e,permission:t,privileges:r,childCollapsed:n,didChildCollapsed:i,toastMessageCallback:o})=>{const[a,s]=O.useState(n),c=pr(),u=c.getRestrictedByDefault(),d=c.getPrivileges();return O.useEffect(()=>{n===!0&&s(!0)},[n]),C.jsxs(C.Fragment,{children:[C.jsx(oa,{privileges:r,permission:t,isChild:!0,depth:e,hasChild:!0,toggleCollapse:()=>{const p=!a;s(p),i==null||i(p)},isRestrictedByDefault:u,allPrivileges:d,collapsed:a,toastMessageCallback:o}),!a&&C.jsxs(C.Fragment,{children:[t.attributes.map((p,v)=>C.jsx(oa,{privileges:r,permission:p,depth:e+1,isRestrictedByDefault:u,allPrivileges:d,toastMessageCallback:o},`${p.type}-${v}`)),t.methods.map((p,v)=>C.jsx(oa,{privileges:r,permission:p,depth:e+1,isRestrictedByDefault:u,allPrivileges:d,toastMessageCallback:o},`${p.type}-${v}`))]})]})},Fse=({selectedRole:e})=>{const[t,r]=O.useState(null),[n,i]=O.useState(null),{styles:o,attributes:a}=rd(t,n,{modifiers:[{name:"offset",options:{offset:[0,10]}}]}),s=pr(),c=s.getRestrictedByDefault(),u=s.getPrivileges(),[d,p]=O.useState([]),[v,h]=O.useState(""),x=s.getCatalogMethods(),m=s.getDataclasses(),b=s.getSingletons(),[w,y]=O.useState({}),[_,S]=O.useState([]);O.useEffect(()=>{const $=Vie(x,Object.values(m),Object.values(b));y($)},[e]);function E($){const Y=["datastore","singleton","dataclass","attribute","dsMethod","dataclassMethod","entityMethod","entityselMethod","singletonMethod"];return $.sort((U,Q)=>{const k=Y.indexOf(U.type),W=Y.indexOf(Q.type);return k!==W?k-W:U.applyTo.toLowerCase()>Q.applyTo.toLowerCase()?1:-1})}O.useEffect(()=>{S(E(k_(v,x,Object.values(m),Object.values(b)).filter($=>d.length?d.includes($.type):!0)))},[d,v]);const[I,N]=O.useState(!1),T=$=>{p(Y=>Y.some(U=>$.includes(U))?Y.filter(U=>!$.includes(U)):[...Y,...$])},A=s.getRoles(),B={toggleAllCollapsed:$=>{$.allCollapsed=!$.allCollapsed},toggleChildCollapsed:$=>{$.childCollapsed=!$.childCollapsed},setAllCollapsed:($,Y)=>{$.allCollapsed=Y},setChildCollapsed:($,Y)=>{$.childCollapsed=Y}},L=O.useMemo(()=>{const $=Object.values(u).find(W=>W.privilege==="guest"),Y=A[e],U=Y?Object.fromEntries(Y.privileges.map(W=>[W,u[W]]).filter(([,W])=>!!W)):{};if(c)return{rolePrivs:U,otherPrivs:$?{[$.id]:$}:{}};const Q=$?{[$.id]:{...$,active:!0}}:{},k=Object.fromEntries(Object.entries(u).filter(([W])=>W!==($==null?void 0:$.id)&&!(Y!=null&&Y.privileges.includes(W))).map(([W,J])=>[W,{...J,active:!1}]));return{rolePrivs:U,otherPrivs:{...Q,...k}}},[u,A,e,c]),{state:{allCollapsed:D,childCollapsed:z},dispatch:P}=fe.useEnhancedState({allCollapsed:!1,childCollapsed:!1},B,"Table Collapse Store"),K=()=>{fe.toastSubject.next({kind:"info",markdown:!0,message:"**Info:** You can add or modify permissions only in the Privilege section.",customIcon:_e.FdInfoCircle})};return C.jsxs($d,{className:"z-20 h-full flex-1 overflow-auto p-[15px] pt-0",style:{maxHeight:"calc(100vh - 5.5rem - 85px - 20px)"},children:[C.jsxs("table",{className:"relative h-full w-full border-collapse",children:[C.jsx("thead",{className:"sticky top-0 z-20 bg-panel-1",children:C.jsxs("tr",{className:"border-b border-grey-100",children:[C.jsx("td",{className:"py-2",children:C.jsxs("div",{className:"flex items-center space-x-2",children:[C.jsx(fe.Tooltip,{label:"Collapse All",placement:"top",container:xr(),children:C.jsx(Zt,{color:"white",variant:"ghost",disabled:D,onClick:()=>{z?(P.setAllCollapsed(!0),N(!0)):P.setChildCollapsed(!0)},children:C.jsx(_e.FdCollapseAll,{})})}),C.jsx("div",{className:"relative w-56",children:C.jsx(wt.Root,{children:C.jsxs(wt.Group,{children:[C.jsx(wt.Icon,{children:C.jsx(_e.FdSearch,{})}),C.jsx(wt.Field,{type:"text",placeholder:"Search",value:v,onChange:$=>{h($.target.value)}}),C.jsx(un.Popover,{className:"flex items-center",children:({open:$})=>C.jsxs(C.Fragment,{children:[C.jsx(un.Popover.Button,{ref:r,children:C.jsx(wt.Icon,{isAction:!0,children:C.jsx(_e.FdAdjust,{})})}),$&&C.jsx(Td,{children:C.jsx(un.Popover.Panel,{ref:i,style:o.popper,...a.popper,className:"z-50",static:!0,children:C.jsxs(dr,{depth:3,borderType:"light",className:"rounded-md border px-4 py-2.5 text-xs",children:[C.jsx("h5",{className:"mb-2 text-sm",children:"Filter"}),C.jsxs("div",{className:"space-y-2 text-s",children:[C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.includes("datastore"),onChange:()=>{T(["datastore"])},label:"Datastore",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.includes("dataclass"),onChange:()=>{T(["dataclass"])},label:"Dataclass",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.includes("singleton"),onChange:()=>{T(["singleton"])},label:"Singleton",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.some(Y=>["method","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"].includes(Y)),onChange:()=>{T(["method","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"])},label:"Functions",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.includes("attribute"),onChange:()=>{T(["attribute"])},label:"Attribute",size:"sm"})})]})]})})})]})})]})})})]})}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"read"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Create"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Update"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Delete"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Execute"})]})}),C.jsx("tbody",{className:"relative",children:d.length||v?_.map(($,Y)=>C.jsx(oa,{privileges:L,permission:$,depth:0,inSearch:!0,isRestrictedByDefault:c,allPrivileges:u,toastMessageCallback:K},`${$.type}-${Y}`)):Object.values(w).map(($,Y)=>C.jsxs(O.Fragment,{children:[C.jsx(oa,{privileges:L,permission:$,isRestrictedByDefault:c,allPrivileges:u,hasChild:!0,depth:0,toggleCollapse:()=>{const U=!I;N(U),P.setAllCollapsed(!U&&D?!1:D)},collapsed:I,toastMessageCallback:K}),$.type==="datastore"&&!I?C.jsxs(C.Fragment,{children:[$.methods.map((U,Q)=>C.jsx(oa,{privileges:L,isRestrictedByDefault:c,allPrivileges:u,permission:U,depth:1,collapsed:D||!1,toastMessageCallback:K},`${U.type}-${Q}`)),$.dataClasses.map((U,Q)=>C.jsx(x2,{depth:1,privileges:L,permission:U,childCollapsed:z,didChildCollapsed:k=>{P.setChildCollapsed(k?z:!1)},toastMessageCallback:K},`${U.type}-${Q}`))]}):null,$.singletons.map((U,Q)=>C.jsx(x2,{depth:0,privileges:L,permission:U,childCollapsed:D,didChildCollapsed:k=>{P.setAllCollapsed(k?D:!1)},toastMessageCallback:K},`${U.type}-${Q}`))]},`${$.type}-${Y}`))})]}),(v||d.length)&&!_.length?C.jsx(zse,{children:"The Permission you're looking for can't be found "}):null]})},$se=()=>{const e=pr(),t=e.getRoles(),[r,n]=O.useState(null),[i,o]=O.useState(null),[a,s]=O.useState(""),[c,u]=O.useState(null),{styles:d,attributes:p}=rd(r,i,{modifiers:[{name:"offset",options:{offset:[-10,10]}}],placement:"right-start"});O.useEffect(()=>{s(""),u(null)},[i]);const v=()=>{if(!a)throw new Error("Please enter a valid name");if(Object.values(t).find(b=>b.role.toLowerCase()===a.toLowerCase()))throw new Error(`A role with the name ${a} already exists`);const x=EB.generate(),m=fe.createRole(x,a,t);e.actions.updateRoles(m)};return C.jsx(un.Popover,{children:({open:h,close:x})=>{const m=()=>{u(null);try{fe.validateName(a),v(),x()}catch(b){u(b.message)}};return C.jsxs(C.Fragment,{children:[C.jsx(un.Popover.Button,{className:"rounded","data-cy":"New-priv-btn",ref:n,children:C.jsx(Zt,{variant:"ghost",color:"white",children:C.jsx(_e.FdPlus,{className:"h-4 w-4"})})}),h&&C.jsx(Td,{children:C.jsx(un.Popover.Panel,{ref:o,style:d.popper,...p.popper,"data-cy":"New-priv-pop-up",className:"z-50",static:!0,children:C.jsxs(dr,{className:"min-w-[256px] border rounded px-4 py-2 text-xs shadow-md",depth:3,borderType:"light",children:[C.jsx("h5",{className:"mb-2 text-xs font-semibold",children:"Create New Role"}),C.jsx("div",{className:"mt-2",children:C.jsxs("label",{className:"flex items-center space-x-4",children:[C.jsx("span",{children:"Name"}),C.jsxs(wt.Root,{color:c?"negative":"primary",className:"w-full",children:[C.jsx(wt.Group,{children:C.jsx(wt.Field,{autoFocus:!0,value:a,onChange:b=>s(b.target.value),onKeyDown:b=>{b.key==="Enter"&&m()},type:"text"})}),c&&C.jsx(wt.Message,{children:c})]})]})}),C.jsxs("div",{className:"mt-4 flex items-center justify-center space-x-2",children:[C.jsx(Zt,{onClick:()=>{m()},children:"Create"}),C.jsx(Zt,{color:"white",variant:"outline",onClick:()=>x(),children:"Cancel"})]})]})})})]})}})},Hse=()=>{const t=pr().getRoles(),{selectedRole:r}=Y1();return C.jsxs("div",{className:"flex flex-1 h-full",children:[C.jsxs(dr,{depth:1,className:"flex h-full w-[356px] flex-col",children:[C.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between px-3.5 py-[10px]",children:[C.jsxs("div",{className:"flex items-center space-x-1",children:[C.jsx("span",{children:C.jsx(_e.FdGroup,{className:"h-[14px] w-[14px]"})}),C.jsx("span",{className:"text-[11px] font-semibold",children:"Roles"})]}),C.jsx($se,{})]}),C.jsx("div",{className:"flex-1 space-y-4 overflow-auto p-4 pb-10 pt-1",children:Object.values(t).length>0?Object.values(t).sort((n,i)=>fe.localeCompare(n.role,i.role)).map((n,i)=>C.jsx(qse,{role:n},i)):C.jsx("div",{className:"flex h-full items-center justify-center",children:C.jsx("div",{className:"flex flex-1 items-center justify-center text-inactive-text",children:C.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[C.jsx(_e.FdInfoBold,{className:"h-10 w-10"}),C.jsx("div",{className:"font-semibold",children:"There are no roles"}),C.jsxs("div",{className:"flex items-center text-sm",children:["Create a new role by clicking on the"," ",C.jsx(_e.FdPlus,{className:"ml-2 inline h-4 w-4"})]})]})})})})]}),C.jsx(dr,{depth:1,className:Yr("relative flex h-full w-full flex-1 flex-col items-stretch overflow-x-auto",{"border-l-[0.5px]":r}),children:C.jsx("div",{className:"flex h-full w-full select-none flex-col",children:r?C.jsxs(C.Fragment,{children:[C.jsx(Lse,{}),C.jsx(Fse,{selectedRole:r})]}):C.jsx(ZL,{tab:"Role"})})})]})},xF=()=>{const e=pr(),t=e.getQodly(),r=e.getSelectedTab(),n=e.getForceLogin(),i=e.getRestrictedByDefault(),o=O.useRef();return C.jsx("div",{className:"absolute inset-0 flex flex-1 overflow-hidden",children:C.jsx("div",{className:"relative flex flex-1 overflow-x-auto","data-cy":"Roles&Privileges-editor-cy",ref:a=>o.current=a,children:C.jsxs("div",{className:"flex w-full flex-col",children:[C.jsx(OK,{activeTab:r,forceLogin:n,restrictedByDefault:i,onTabChange:a=>{e.actions.toggleTab(a)},onForceLoginChange:a=>{e.actions.toggleForceLogin(a)},onRestrictedByDefaultChange:a=>{e.actions.toggleRestrictedByDefault(a)},qodly:t}),r==="roles"?C.jsx(CK,{children:C.jsx(Hse,{})}):C.jsx(Dse,{})]})})})},Vse=()=>{const{modals:e,closeModal:t,editModal:r}=Poe();return C.jsx(C.Fragment,{children:e.map((n,i)=>C.jsx(fe.Modal,{hasOverlay:i===0,...n,onClose:t,onEdit:r,container:xr()},n.id))})},wF=e=>{if(!e)return fe.rolesToAPI(fe.sanitizeRoles({}));try{return fe.rolesToAPI(fe.sanitizeRoles(JSON.parse(e)))}catch{return fe.rolesToAPI(fe.sanitizeRoles({}))}},Wse=({initialValue:e,onChange:t,...r})=>{const n=pr(),i=n.getRolesFlags(),o=n.getRolesAndPrivileges(),a=O.useMemo(()=>wF(e),[e]),s=O.useRef(o),c=O.useRef(a),u=O.useRef(a);return O.useEffect(()=>{s.current=o},[o]),O.useEffect(()=>{lo.isEqual(a,u.current)||(u.current=a,c.current=a,!lo.isEqual(a,s.current)&&n.actions.setRolesContent({content:a,flags:{touched:!1}}))},[n,a]),fe.useDidMountEffect(()=>{if(!(!t||!i.touched)&&!lo.isEqual(o,c.current))try{const d=JSON.stringify(o,null,2);t(d),c.current=o}catch(d){console.error("[Roles Editor Standalone] Error on value stringify:",d)}},[o,i.touched,t]),C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"relative h-screen z-10 overflow-hidden",children:C.jsx(xF,{...r})}),C.jsx(Vse,{})]})},Use=e=>{const t=Toe();return C.jsx(vB,{adapter:t,children:C.jsx(fe.TipsProvider,{children:C.jsx(Wse,{...e})})})},Gse=({initialValue:e,...t})=>{const r=O.useMemo(()=>({...fe.sanitizeRoles(wF(e)),flags:{touched:!1}}),[e]);return C.jsx(Noe,{initialState:r,children:C.jsx(Use,{initialValue:e,...t})})};exports.ROLES_EDITOR_SCOPE_CLASS=w2.ROLES_EDITOR_SCOPE_CLASS;exports.EditorStateAdapterProvider=vB;exports.Roles=xF;exports.Standalone=Gse;exports.useReduxAdapter=Yie;
113
+ ressources`,container:xr(),children:C.jsx(Zt,{color:"white",variant:"ghost",onClick:S,children:C.jsx(_e.FdReload,{})})})}),C.jsx(Kr,{icon:C.jsx(_e.FdBulb,{}),label:"Delete all the non existing resources from privileges",container:xr(),children:C.jsx(Zt,{color:"white",variant:"ghost",onClick:L,disabled:!B,children:C.jsx(_e.FdClean,{className:"h-4 w-4"})})})]})}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Read"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Create"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Update"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Delete"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Execute"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Promote"})]})}),T.length?C.jsx("tbody",{children:T.map((D,z)=>{const P=D.permissions.some(K=>K.from.length>0);return C.jsxs("tr",{className:Yr("group even:bg-white/5 hover:bg-input-bg",{"opacity-60":D.exists===!1}),children:[C.jsxs("td",{className:Yr("group flex items-center gap-3 py-2 text-xs group-hover:rounded-l group-hover:bg-input-bg ",D.exists===!1?"text-negative-text":""),children:[bF(D.type),D.resource,C.jsx(Kr,{label:"Remove Permission",container:xr(),children:C.jsx(Zt,{color:"white",variant:"ghost",disabled:P,onClick:()=>{P?fe.toastSubject.next({kind:"info",markdown:!0,message:`<div className="flex gap-x-3"><h3 className="font-bold">Info:</h3><p className="font-normal">Inherited permissions can't be removed</p></div>`,customIcon:_e.FdInfoBold}):_({applyTo:D.resource,type:D.type})},className:"opacity-0 group-hover:opacity-100",children:C.jsx(_e.FdPlus,{className:"h-4 w-4 rotate-45 transform"})})})]}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"read",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"create",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"update",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"drop",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:C.jsx(Uo,{promoted:w[D.resource],permissions:D.permissions,showIncluded:r,label:"execute",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})}),C.jsx("td",{className:"py-2 text-center group-hover:rounded-r group-hover:bg-input-bg",children:C.jsx(Uo,{permissions:D.permissions,showIncluded:r,label:"promote",onToggle:K=>A(D,K),onSelect:t,privileges:n,exists:D.exists})})]},z)})}):null]}),!N.length&&h?C.jsx(b2,{children:"The Permission you're looking for can't be found "}):null,!N.length&&!h?C.jsxs(b2,{children:["This Privilege has no Permissions configured yet ",C.jsx("br",{}),'Add a new permission by using the "Create a permission" input above']}):null]})},Mse=({onCreate:e})=>{const t=pr(),r=t.getPrivileges(),[n,i]=O.useState(null),[o,a]=O.useState(null),[s,c]=O.useState(""),[u,d]=O.useState(null),{styles:p,attributes:v}=rd(n,o,{modifiers:[{name:"offset",options:{offset:[-10,10]}}],placement:"right-start"});O.useEffect(()=>{c(""),d(null)},[o]);const h=x=>{d(null);try{const m=fe.createPrivilege(s,r),b=Object.values(m).find(w=>w.privilege===s);t.actions.updatePrivileges(m),b&&e(b),setTimeout(()=>{x()},0)}catch(m){d(m.message)}};return C.jsx(un.Popover,{children:({open:x,close:m})=>C.jsxs(C.Fragment,{children:[C.jsx(un.Popover.Button,{className:"rounded","data-cy":"New-priv-btn",ref:i,children:C.jsx(Zt,{variant:"ghost",color:"white",children:C.jsx(_e.FdPlus,{className:"h-4 w-4"})})}),x&&C.jsx(Td,{children:C.jsx(un.Popover.Panel,{ref:a,style:p.popper,...v.popper,"data-cy":"New-priv-pop-up",className:"z-50",static:!0,children:C.jsxs(dr,{className:"min-w-[256px] border rounded px-4 py-2 text-xs shadow-md",depth:3,borderType:"light",children:[C.jsx("h5",{className:"mb-2 text-xs font-semibold",children:"Create New Privilege"}),C.jsx("div",{className:"mt-2",children:C.jsxs("label",{className:"flex items-center space-x-4",children:[C.jsx("span",{children:"Name"}),C.jsxs(wt.Root,{className:"w-full",color:u?"negative":"primary",children:[C.jsx(wt.Group,{children:C.jsx(wt.Field,{autoFocus:!0,value:s,onChange:b=>c(b.target.value),onKeyDown:b=>{b.key==="Enter"&&h(m)},type:"text"})}),u&&C.jsx(wt.Message,{children:u})]})]})}),C.jsxs("div",{className:"mt-4 flex items-center justify-center space-x-2",children:[C.jsx(Zt,{onClick:()=>{h(m)},children:"Create"}),C.jsx(Zt,{color:"white",variant:"outline",onClick:()=>m(),children:"Cancel"})]})]})})})]})})},Dse=()=>{const e=pr(),t=e.getCatalog(),r=e.getPrivileges(),n=O.useMemo(()=>{if(t===null)return r;const u=fB(r,Object.values((t==null?void 0:t.dataClasses)??{}));return pB(u,t)},[r,t]),[i,o]=O.useState(null),a=O.useMemo(()=>Object.keys(n),[n]);O.useEffect(()=>{i&&n[i.id]||!a.length||o(n[a[0]])},[n]),O.useEffect(()=>{a.length<2&&c(!0)},[a.length]);const[s,c]=O.useState(!0);return C.jsxs("div",{className:"flex flex-1 h-full",children:[C.jsxs(dr,{depth:1,className:"flex h-full w-[356px] flex-col",children:[C.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between px-3.5 py-[10px]",children:[C.jsxs("div",{className:"flex items-center space-x-1",children:[C.jsx("span",{children:C.jsx(_e.FdGroup,{className:"h-[14px] w-[14px]"})}),C.jsx("span",{className:"text-[11px] font-semibold",children:"Privileges"})]}),C.jsx(Mse,{onCreate:u=>{o(u)}})]}),C.jsx(Moe,{privileges:n,selectedPrivilege:i,selectPrivilege:u=>{o(u)}})]}),i&&n[i.id]?C.jsxs(dr,{depth:1,className:"privileges-container relative flex flex-1 flex-col overflow-x-auto border-l-[0.5px]",children:[C.jsxs("div",{className:"mb-1 flex h-full w-full flex-col items-stretch",children:[i.privilege!=="guest"?C.jsx(koe,{privileges:n,selectedPrivilege:i,onSelect:u=>o(r[u]),setShowIncluded:c,showIncluded:s}):null,C.jsx(Ase,{privileges:n,selectedPrivilege:i,onSelect:u=>o(r[u]),showIncluded:s})]}),C.jsx(jse,{privileges:n,selectedPrivilege:i,setSelectedPrivilege:o})]}):C.jsx(ZL,{tab:"Privilege"})]})},jse=({privileges:e,selectedPrivilege:t,setSelectedPrivilege:r})=>{const[n,i]=O.useState(!1);return C.jsx(fe.Panel,{path:fe.ROLES_TAB_PATH,isOpen:n,onOpen:()=>i(!0),onClose:()=>i(!1),children:C.jsx("div",{className:"h-full w-full px-3 pb-3",children:C.jsx(dr,{depth:2,className:"h-full w-full rounded",children:C.jsx($ie,{dict:e,data:fe.getGraphData(t.id,e),onSelect:o=>r(e[o])})})})})},qse=({role:e})=>{var E;const t=pr(),[r,n]=O.useState(e),[i,o]=O.useState(e.role),[a,s]=O.useState(null),c=t.getPrivileges(),u=((E=r.privileges)==null?void 0:E.filter(I=>c[I]&&c[I].privilege!=="guest").length)||0,d=t.getRoles(),{selectedRole:p,selectRole:v}=Y1(),[h,x]=O.useState(!1),m=fe.useOutsideClick(()=>{h&&w()});fe.useDidMountEffect(()=>{i!==e.role&&o(e.role)},[e.role]),O.useEffect(()=>{e.role||x(!0)},[]),O.useEffect(()=>{n(e)},[e]);const b=()=>{s(null),x(!0)},w=()=>{s(null),e.role&&e.role===i&&x(!1);try{const I=fe.saveRole({...r,role:i},d);t.actions.updateRoles(I),x(!1)}catch(I){s(I.message)}},y=async I=>{I.stopPropagation();const{confirmed:N}=await t.actions.openModal({title:"Delete Role",type:fe.ModalType.CONFIRM,color:fe.ModalColor.DANGER,message:"Are you sure you want to remove this Role?",icon:"FdWarningDanger"});N&&_()},_=()=>{const I=fe.removeRole(r.id,d),N=Object.keys(I);if(p!==r.id){t.actions.updateRoles(I);return}if(N.length===0)v(null);else{const T=Object.keys(d),A=T.indexOf(r.id),B=Math.max(0,A-1),L=T[B];A===0?v(N[0]):I[L]?v(L):v(N[0])}t.actions.updateRoles(I)},S=(I=null)=>{if(I&&I.stopPropagation(),!e.role){_();return}x(!1),o(e.role)};return C.jsx(C.Fragment,{children:C.jsxs(dr,{depth:4,borderType:p===r.id?"primary":p!==r.id?"light":"default",className:Yr("rounded border p-2"),role:"button","data-cy":"privilegeCard",onClick:()=>{v(r.id)},ref:m,children:[C.jsx("div",{className:"flex items-center justify-between",children:C.jsxs("div",{className:"flex flex-1 items-center",children:[C.jsx("span",{className:"mr-4",children:C.jsx(_e.FdGroup,{className:"h-6 w-6"})}),h?C.jsxs(wt.Root,{color:a?"negative":"primary",className:"flex-1 mr-2",children:[C.jsx(wt.Group,{children:C.jsx(wt.Field,{type:"text",value:i,onChange:({target:{value:I}})=>{o(I)},onKeyDown:I=>{I.key==="Enter"&&w(),I.key==="Escape"&&S()},onBlur:()=>S(),placeholder:"role",autoComplete:"off",autoFocus:!0})}),a&&C.jsx(wt.Message,{children:a})]}):C.jsx("span",{className:"inline-block grow overflow-hidden truncate whitespace-nowrap text-xs font-bold",title:i,children:r.role}),C.jsx("div",{className:Yr("justify-between ml-auto flex w-fit items-center gap-x-2"),children:h?C.jsxs(C.Fragment,{children:[C.jsx(Zt,{color:"white",variant:"ghost",onClick:w,children:C.jsx(_e.FdSave,{className:"h-4 w-4"})}),C.jsx(Zt,{color:"white",variant:"ghost",onClick:S,children:C.jsx(_e.FdClose,{className:"h-4 w-4"})})]}):C.jsxs(C.Fragment,{children:[C.jsx(Zt,{color:"white",variant:"ghost",onClick:b,children:C.jsx(_e.FdPen,{className:"h-4 w-4"})}),C.jsx(Zt,{color:"white",variant:"ghost",onClick:I=>y(I),children:C.jsx(_e.FdTrash,{className:"h-4 w-4"})})]})})]})}),C.jsxs("span",{className:Yr("ml-[43px] py-1 text-xs"),children:[u," Privilege",u>1?"s":""]})]})})},yF=(e,t)=>e?t[e]:null,y2=(e,t,r)=>{const n=yF(e,r);return n?Object.values(r).reduce((i,o)=>o.id===e?n.privileges.includes(t)?{...i,[n.id]:{...n,privileges:n.privileges.filter(a=>a!==t)}}:{...i,[n.id]:{...n,privileges:[...n.privileges,t]}}:{...i,[o.id]:o},{}):r},Lse=()=>{const e=pr(),t=e.getPrivileges(),r=e.getRoles(),{selectedRole:n}=Y1(),i=yF(n,r),o=(a,s)=>s&&s.privileges.includes(a.id);return C.jsxs(dr,{depth:1,className:"w-full border-b p-4 ",children:[C.jsx("div",{className:"mb-4 flex items-center gap-x-5",children:C.jsx("h4",{className:"text-[13px] font-semibold ",children:"Privileges"})}),C.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[C.jsx(Zc,{"data-cy":"item=>Permisions",className:"italic opacity-90",children:"guest"}),Object.values(t).filter(a=>o(a,i)&&a.privilege!=="guest").map((a,s)=>C.jsxs(Zc,{"data-cy":"item=>Permisions",color:"primary",onClick:()=>{const c=y2(i.id,a.id,r);e.actions.updateRoles(c)},children:[a.privilege,C.jsx(_e.FdPlus,{className:"rotate-45 transform"})]},s)),Object.values(t).filter(a=>!o(a,i)&&a.privilege!=="guest").map((a,s)=>C.jsxs(Zc,{"data-cy":"item=>Permisions",color:"dark",onClick:()=>{const c=y2(i.id,a.id,r);e.actions.updateRoles(c)},children:[a.privilege,C.jsx(_e.FdPlus,{})]},s))]})]})},zse=({children:e})=>C.jsx("div",{className:"h-full w-full",children:C.jsx("div",{className:"flex h-full w-full flex-1 items-center justify-center",children:C.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 py-4 text-inactive-text",children:[C.jsx(_e.FdInfoBold,{className:"absolute -right-full h-10 w-10 translate-x-1"}),C.jsx("div",{className:"text-center text-sm",children:e})]})})}),Hw=(e,t,r,n=!1)=>{const i=e.applyTo,o=e.type===fe.EPermissionType.DATACLASS?"ds":i.split(".")[0],a={...t,...r},s=()=>({value:!n,inherited:!1,from:[],explicitly:!1}),c={read:s(),create:s(),update:s(),drop:s(),execute:s(),promote:s()},u=p=>{p.forEach(v=>{a[v]&&(a[v].resources.forEach(h=>{if(h.resource===i||h.resource===o){const x=Hw(e,t,{[v]:a[v]},n);Object.values(h.permissions).forEach(m=>{c[m.name].explicitly||(!c[m.name].from.includes(a[v].privilege)&&m.checked&&c[m.name].from.push(a[v].privilege),c[m.name].inherited=c[m.name].inherited||x[m.name].value||x[m.name].inherited)})}}),a[v].includes.length>0&&u(a[v].includes))})};if(Object.values(r).forEach(p=>{p.resources.forEach(v=>{v.resource===i&&Object.values(v.permissions).forEach(h=>{h.checked&&(c[h.name].explicitly=!0,n&&(c[h.name].value=!0))})}),(p.includes.length>0||p.privilege==="guest")&&u(p.includes)}),Object.values(t).forEach(p=>{p.resources.forEach(v=>{v.resource===i&&(p.privilege==="guest"?Object.values(v.permissions).forEach(h=>{h.checked&&(c[h.name].explicitly=!0,n&&(c[h.name].value=!0))}):Object.values(v.permissions).forEach(h=>{!c[h.name].explicitly&&h.checked&&(n?c[h.name].value=!0:c[h.name].value=!1)}))})}),(n?Object.entries(c).some(([p,v])=>p!=="promote"&&!v.value&&!v.explicitly):Object.entries(c).some(([p,v])=>p!=="promote"&&v.value&&!v.explicitly))&&![fe.EPermissionType.DATASTORE,fe.EPermissionType.SINGLETON].includes(e.type)){const p={applyTo:o,type:e.type===fe.EPermissionType.DATACLASS?fe.EPermissionType.DATASTORE:e.type===fe.EPermissionType.SINGLETON_METHOD?fe.EPermissionType.SINGLETON:fe.EPermissionType.DATACLASS},v=Hw(p,t,r,n),h=x=>{let m=c[x].value;return n?!c[x].value&&!c[x].explicitly&&(m=v[x].value):c[x].value&&!c[x].explicitly&&(m=v[x].value),{value:m,inherited:c[x].inherited||v[x].inherited,from:c[x].from.length>0?c[x].from:v[x].from,explicitly:c[x].explicitly}};return{read:h("read"),create:h("create"),update:h("update"),drop:h("drop"),execute:h("execute"),promote:h("promote")}}return{read:c.read,create:c.create,update:c.update,drop:c.drop,execute:c.execute,promote:c.promote}},Bse=e=>{switch(e){case"dataclass":return C.jsx(_e.FdTableHeader,{className:"h-6 w-6"});case"singleton":return C.jsx(_e.FdSingleton,{className:"h-6 w-6"});case"datastore":return C.jsx(_e.FdModel3,{className:"h-6 w-6"});case"attribute":return C.jsx(_e.FdTableColumn,{className:"h-6 w-6"});case"method":return C.jsx(_e.FdCode,{className:"h-6 w-6"});case"singletonMethod":return C.jsx(_e.FdFunctionSingleton,{className:"h-6 w-6"});case"entityselMethod":return C.jsx(_e.FdFunctionSelection,{className:"h-6 w-6"});case"entityMethod":return C.jsx(_e.FdFunctionEntity,{className:"h-6 w-6"});case"dsMethod":return C.jsx(_e.FdFunctionDatastore,{className:"h-6 w-6"});case"dataclassMethod":return C.jsx(_e.FdFunctionDataclass,{className:"h-6 w-6"});default:return C.jsx(_e.FdTableHeader,{className:"h-6 w-6"})}},oa=({privileges:e,permission:t,hasChild:r,depth:n,isChild:i=!1,className:o,inSearch:a,toggleCollapse:s,collapsed:c,isRestrictedByDefault:u,toastMessageCallback:d})=>{const[p,v]=t.applyTo.split("."),h=O.useMemo(()=>Hw(t,e.otherPrivs,e.rolePrivs,u),[e,t,u]);return C.jsxs("tr",{className:Yr("group even:bg-white/5 hover:bg-input-bg",o),children:[C.jsxs("td",{className:Yr("flex h-full w-full items-stretch gap-3 p-0 text-xs group-hover:rounded-l group-hover:bg-input-bg",{"px-1":a}),children:[Array(n).fill("").map((x,m)=>C.jsx("div",{className:Yr("ml-1.5 mr-1 w-[2px] bg-grey-100",{"mr-0.5":i})},m)),C.jsxs("div",{className:"flex items-center gap-3 py-2",children:[r&&C.jsx("button",{onClick:s,className:"w-3",children:c?C.jsx(_e.FdRight,{className:"inline h-4 w-4"}):C.jsx(_e.FdDown,{className:"inline h-4 w-4"})}),Bse(t.type),a?t.applyTo:v||p]})]}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[fe.EPermissionType.ATTRIBUTE,fe.EPermissionType.DATASTORE,fe.EPermissionType.DATACLASS].includes(t.type)&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.read.value||h.read.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.read.value&&h.read.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.read.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.read.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[fe.EPermissionType.ATTRIBUTE,fe.EPermissionType.DATASTORE,fe.EPermissionType.DATACLASS].includes(t.type)&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.create.value||h.create.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.create.value&&h.create.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.read.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.read.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[fe.EPermissionType.ATTRIBUTE,fe.EPermissionType.DATASTORE,fe.EPermissionType.DATACLASS].includes(t.type)&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.update.value||h.update.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.update.value&&h.update.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.update.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.update.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})}),C.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[fe.EPermissionType.ATTRIBUTE,fe.EPermissionType.DATASTORE,fe.EPermissionType.DATACLASS].includes(t.type)&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.drop.value||h.drop.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.drop.value&&h.drop.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.drop.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.drop.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})}),C.jsx("td",{className:"py-2 text-center group-hover:rounded-r group-hover:bg-input-bg",children:t.type!=="attribute"&&C.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",children:[C.jsx(or,{value:h.execute.value||h.execute.inherited,onClick:d,isDisabled:!0}),C.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!h.execute.value&&h.execute.inherited?C.jsx(Kr,{container:xr(),delay:100,label:C.jsx("div",{className:"space-y-1 p-1",children:h.execute.from.length?C.jsxs("div",{className:"flex items-start",children:[C.jsx(_e.FdBulb,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),C.jsxs("p",{className:"flex flex-col gap-y-2",children:[C.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),C.jsx("ul",{children:h.execute.from.map((x,m)=>C.jsx("li",{className:"cursor-pointer list-disc font-bold",children:x},m))})]})]}):null}),children:C.jsx(_e.FdInfoBold,{className:"h-4 w-4"})}):""})]})})]})},x2=({depth:e,permission:t,privileges:r,childCollapsed:n,didChildCollapsed:i,toastMessageCallback:o})=>{const[a,s]=O.useState(n),c=pr(),u=c.getRestrictedByDefault(),d=c.getPrivileges();return O.useEffect(()=>{n===!0&&s(!0)},[n]),C.jsxs(C.Fragment,{children:[C.jsx(oa,{privileges:r,permission:t,isChild:!0,depth:e,hasChild:!0,toggleCollapse:()=>{const p=!a;s(p),i==null||i(p)},isRestrictedByDefault:u,allPrivileges:d,collapsed:a,toastMessageCallback:o}),!a&&C.jsxs(C.Fragment,{children:[t.attributes.map((p,v)=>C.jsx(oa,{privileges:r,permission:p,depth:e+1,isRestrictedByDefault:u,allPrivileges:d,toastMessageCallback:o},`${p.type}-${v}`)),t.methods.map((p,v)=>C.jsx(oa,{privileges:r,permission:p,depth:e+1,isRestrictedByDefault:u,allPrivileges:d,toastMessageCallback:o},`${p.type}-${v}`))]})]})},Fse=({selectedRole:e})=>{const[t,r]=O.useState(null),[n,i]=O.useState(null),{styles:o,attributes:a}=rd(t,n,{modifiers:[{name:"offset",options:{offset:[0,10]}}]}),s=pr(),c=s.getRestrictedByDefault(),u=s.getPrivileges(),[d,p]=O.useState([]),[v,h]=O.useState(""),x=s.getCatalogMethods(),m=s.getDataclasses(),b=s.getSingletons(),[w,y]=O.useState({}),[_,S]=O.useState([]);O.useEffect(()=>{const $=Vie(x,Object.values(m),Object.values(b));y($)},[e]);function E($){const Y=["datastore","singleton","dataclass","attribute","dsMethod","dataclassMethod","entityMethod","entityselMethod","singletonMethod"];return $.sort((U,Q)=>{const k=Y.indexOf(U.type),W=Y.indexOf(Q.type);return k!==W?k-W:U.applyTo.toLowerCase()>Q.applyTo.toLowerCase()?1:-1})}O.useEffect(()=>{S(E(k_(v,x,Object.values(m),Object.values(b)).filter($=>d.length?d.includes($.type):!0)))},[d,v]);const[I,N]=O.useState(!1),T=$=>{p(Y=>Y.some(U=>$.includes(U))?Y.filter(U=>!$.includes(U)):[...Y,...$])},A=s.getRoles(),B={toggleAllCollapsed:$=>{$.allCollapsed=!$.allCollapsed},toggleChildCollapsed:$=>{$.childCollapsed=!$.childCollapsed},setAllCollapsed:($,Y)=>{$.allCollapsed=Y},setChildCollapsed:($,Y)=>{$.childCollapsed=Y}},L=O.useMemo(()=>{const $=Object.values(u).find(W=>W.privilege==="guest"),Y=A[e],U=Y?Object.fromEntries(Y.privileges.map(W=>[W,u[W]]).filter(([,W])=>!!W)):{};if(c)return{rolePrivs:U,otherPrivs:$?{[$.id]:$}:{}};const Q=$?{[$.id]:{...$,active:!0}}:{},k=Object.fromEntries(Object.entries(u).filter(([W])=>W!==($==null?void 0:$.id)&&!(Y!=null&&Y.privileges.includes(W))).map(([W,J])=>[W,{...J,active:!1}]));return{rolePrivs:U,otherPrivs:{...Q,...k}}},[u,A,e,c]),{state:{allCollapsed:D,childCollapsed:z},dispatch:P}=fe.useEnhancedState({allCollapsed:!1,childCollapsed:!1},B,"Table Collapse Store"),K=()=>{fe.toastSubject.next({kind:"info",markdown:!0,message:"**Info:** You can add or modify permissions only in the Privilege section.",customIcon:_e.FdInfoCircle})};return C.jsxs($d,{className:"z-20 h-full flex-1 overflow-auto p-[15px] pt-0",style:{maxHeight:"calc(100vh - 5.5rem - 85px - 20px)"},children:[C.jsxs("table",{className:"relative h-full w-full border-collapse",children:[C.jsx("thead",{className:"sticky top-0 z-20 bg-panel-1",children:C.jsxs("tr",{className:"border-b border-grey-100",children:[C.jsx("td",{className:"py-2",children:C.jsxs("div",{className:"flex items-center space-x-2",children:[C.jsx(fe.Tooltip,{label:"Collapse All",placement:"top",container:xr(),children:C.jsx(Zt,{color:"white",variant:"ghost",disabled:D,onClick:()=>{z?(P.setAllCollapsed(!0),N(!0)):P.setChildCollapsed(!0)},children:C.jsx(_e.FdCollapseAll,{})})}),C.jsx("div",{className:"relative w-56",children:C.jsx(wt.Root,{children:C.jsxs(wt.Group,{children:[C.jsx(wt.Icon,{children:C.jsx(_e.FdSearch,{})}),C.jsx(wt.Field,{type:"text",placeholder:"Search",value:v,onChange:$=>{h($.target.value)}}),C.jsx(un.Popover,{className:"flex items-center",children:({open:$})=>C.jsxs(C.Fragment,{children:[C.jsx(un.Popover.Button,{ref:r,children:C.jsx(wt.Icon,{isAction:!0,children:C.jsx(_e.FdAdjust,{})})}),$&&C.jsx(Td,{children:C.jsx(un.Popover.Panel,{ref:i,style:o.popper,...a.popper,className:"z-50",static:!0,children:C.jsxs(dr,{depth:3,borderType:"light",className:"rounded-md border px-4 py-2.5 text-xs",children:[C.jsx("h5",{className:"mb-2 text-sm",children:"Filter"}),C.jsxs("div",{className:"space-y-2 text-s",children:[C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.includes("datastore"),onChange:()=>{T(["datastore"])},label:"Datastore",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.includes("dataclass"),onChange:()=>{T(["dataclass"])},label:"Dataclass",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.includes("singleton"),onChange:()=>{T(["singleton"])},label:"Singleton",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.some(Y=>["method","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"].includes(Y)),onChange:()=>{T(["method","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"])},label:"Functions",size:"sm"})}),C.jsx("div",{className:"flex items-center",children:C.jsx(or,{value:d.includes("attribute"),onChange:()=>{T(["attribute"])},label:"Attribute",size:"sm"})})]})]})})})]})})]})})})]})}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"read"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Create"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Update"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Delete"}),C.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Execute"})]})}),C.jsx("tbody",{className:"relative",children:d.length||v?_.map(($,Y)=>C.jsx(oa,{privileges:L,permission:$,depth:0,inSearch:!0,isRestrictedByDefault:c,allPrivileges:u,toastMessageCallback:K},`${$.type}-${Y}`)):Object.values(w).map(($,Y)=>C.jsxs(O.Fragment,{children:[C.jsx(oa,{privileges:L,permission:$,isRestrictedByDefault:c,allPrivileges:u,hasChild:!0,depth:0,toggleCollapse:()=>{const U=!I;N(U),P.setAllCollapsed(!U&&D?!1:D)},collapsed:I,toastMessageCallback:K}),$.type==="datastore"&&!I?C.jsxs(C.Fragment,{children:[$.methods.map((U,Q)=>C.jsx(oa,{privileges:L,isRestrictedByDefault:c,allPrivileges:u,permission:U,depth:1,collapsed:D||!1,toastMessageCallback:K},`${U.type}-${Q}`)),$.dataClasses.map((U,Q)=>C.jsx(x2,{depth:1,privileges:L,permission:U,childCollapsed:z,didChildCollapsed:k=>{P.setChildCollapsed(k?z:!1)},toastMessageCallback:K},`${U.type}-${Q}`))]}):null,$.singletons.map((U,Q)=>C.jsx(x2,{depth:0,privileges:L,permission:U,childCollapsed:D,didChildCollapsed:k=>{P.setAllCollapsed(k?D:!1)},toastMessageCallback:K},`${U.type}-${Q}`))]},`${$.type}-${Y}`))})]}),(v||d.length)&&!_.length?C.jsx(zse,{children:"The Permission you're looking for can't be found "}):null]})},$se=()=>{const e=pr(),t=e.getRoles(),[r,n]=O.useState(null),[i,o]=O.useState(null),[a,s]=O.useState(""),[c,u]=O.useState(null),{styles:d,attributes:p}=rd(r,i,{modifiers:[{name:"offset",options:{offset:[-10,10]}}],placement:"right-start"});O.useEffect(()=>{s(""),u(null)},[i]);const v=()=>{if(!a)throw new Error("Please enter a valid name");if(Object.values(t).find(b=>b.role.toLowerCase()===a.toLowerCase()))throw new Error(`A role with the name ${a} already exists`);const x=EB.generate(),m=fe.createRole(x,a,t);e.actions.updateRoles(m)};return C.jsx(un.Popover,{children:({open:h,close:x})=>{const m=()=>{u(null);try{fe.validateName(a),v(),x()}catch(b){u(b.message)}};return C.jsxs(C.Fragment,{children:[C.jsx(un.Popover.Button,{className:"rounded","data-cy":"New-priv-btn",ref:n,children:C.jsx(Zt,{variant:"ghost",color:"white",children:C.jsx(_e.FdPlus,{className:"h-4 w-4"})})}),h&&C.jsx(Td,{children:C.jsx(un.Popover.Panel,{ref:o,style:d.popper,...p.popper,"data-cy":"New-priv-pop-up",className:"z-50",static:!0,children:C.jsxs(dr,{className:"min-w-[256px] border rounded px-4 py-2 text-xs shadow-md",depth:3,borderType:"light",children:[C.jsx("h5",{className:"mb-2 text-xs font-semibold",children:"Create New Role"}),C.jsx("div",{className:"mt-2",children:C.jsxs("label",{className:"flex items-center space-x-4",children:[C.jsx("span",{children:"Name"}),C.jsxs(wt.Root,{color:c?"negative":"primary",className:"w-full",children:[C.jsx(wt.Group,{children:C.jsx(wt.Field,{autoFocus:!0,value:a,onChange:b=>s(b.target.value),onKeyDown:b=>{b.key==="Enter"&&m()},type:"text"})}),c&&C.jsx(wt.Message,{children:c})]})]})}),C.jsxs("div",{className:"mt-4 flex items-center justify-center space-x-2",children:[C.jsx(Zt,{onClick:()=>{m()},children:"Create"}),C.jsx(Zt,{color:"white",variant:"outline",onClick:()=>x(),children:"Cancel"})]})]})})})]})}})},Hse=()=>{const t=pr().getRoles(),{selectedRole:r}=Y1();return C.jsxs("div",{className:"flex flex-1 h-full",children:[C.jsxs(dr,{depth:1,className:"flex h-full w-[356px] flex-col",children:[C.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between px-3.5 py-[10px]",children:[C.jsxs("div",{className:"flex items-center space-x-1",children:[C.jsx("span",{children:C.jsx(_e.FdGroup,{className:"h-[14px] w-[14px]"})}),C.jsx("span",{className:"text-[11px] font-semibold",children:"Roles"})]}),C.jsx($se,{})]}),C.jsx("div",{className:"flex-1 space-y-4 overflow-auto p-4 pb-10 pt-1",children:Object.values(t).length>0?Object.values(t).sort((n,i)=>fe.localeCompare(n.role,i.role)).map((n,i)=>C.jsx(qse,{role:n},i)):C.jsx("div",{className:"flex h-full items-center justify-center",children:C.jsx("div",{className:"flex flex-1 items-center justify-center text-inactive-text",children:C.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[C.jsx(_e.FdInfoBold,{className:"h-10 w-10"}),C.jsx("div",{className:"font-semibold",children:"There are no roles"}),C.jsxs("div",{className:"flex items-center text-sm",children:["Create a new role by clicking on the"," ",C.jsx(_e.FdPlus,{className:"ml-2 inline h-4 w-4"})]})]})})})})]}),C.jsx(dr,{depth:1,className:Yr("relative flex h-full w-full flex-1 flex-col items-stretch overflow-x-auto",{"border-l-[0.5px]":r}),children:C.jsx("div",{className:"flex h-full w-full select-none flex-col",children:r?C.jsxs(C.Fragment,{children:[C.jsx(Lse,{}),C.jsx(Fse,{selectedRole:r})]}):C.jsx(ZL,{tab:"Role"})})})]})},xF=()=>{const e=pr(),t=e.getQodly(),r=e.getSelectedTab(),n=e.getForceLogin(),i=e.getRestrictedByDefault(),o=O.useRef();return C.jsx("div",{className:"absolute inset-0 flex flex-1 overflow-hidden",children:C.jsx("div",{className:"relative flex flex-1 overflow-x-auto","data-cy":"Roles&Privileges-editor-cy",ref:a=>o.current=a,children:C.jsxs("div",{className:"flex w-full flex-col",children:[C.jsx(OK,{activeTab:r,forceLogin:n,restrictedByDefault:i,onTabChange:a=>{e.actions.toggleTab(a)},onForceLoginChange:a=>{e.actions.toggleForceLogin(a)},onRestrictedByDefaultChange:a=>{e.actions.toggleRestrictedByDefault(a)},qodly:t}),r==="roles"?C.jsx(CK,{children:C.jsx(Hse,{})}):C.jsx(Dse,{})]})})})},Vse="object",Wse={forceLogin:{type:"boolean"},restrictedByDefault:{type:"boolean"},privileges:{type:"array",items:{$ref:"#/definitions/Privilege"}},roles:{type:"array",items:{$ref:"#/definitions/Role"}},permissions:{type:"object",properties:{allowed:{type:"array",items:{$ref:"#/definitions/Permission"}}}}},Use={Privilege:{type:"object",properties:{id:{type:"string"},privilege:{type:"string"},includes:{type:"array",items:{type:"string"}}},required:["privilege"]},Role:{type:"object",properties:{id:{type:"string"},role:{type:"string"},privileges:{type:"array",items:{type:"string"}}},required:["role"]},Permission:{type:"object",properties:{applyTo:{type:"string"},type:{enum:["dataclass","method","attribute","datastore","singleton","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"]},subType:{enum:["dsMethod","dataclassMethod","entityMethod","entityselMethod"]},read:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},create:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},update:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},drop:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},execute:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},promote:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]}},required:["applyTo","type"]}},Gse={type:Vse,properties:Wse,definitions:Use},Kse=()=>{const{modals:e,closeModal:t,editModal:r}=Poe();return C.jsx(C.Fragment,{children:e.map((n,i)=>C.jsx(fe.Modal,{hasOverlay:i===0,...n,onClose:t,onEdit:r,container:xr()},n.id))})},wF=e=>{if(!e)return fe.rolesToAPI(fe.sanitizeRoles({}));try{return fe.rolesToAPI(fe.sanitizeRoles(JSON.parse(e)))}catch{return fe.rolesToAPI(fe.sanitizeRoles({}))}},Yse=({initialValue:e,onChange:t,...r})=>{const n=pr(),i=n.getRolesFlags(),o=n.getRolesAndPrivileges(),a=O.useMemo(()=>wF(e),[e]),s=O.useRef(o),c=O.useRef(a),u=O.useRef(a);return O.useEffect(()=>{s.current=o},[o]),O.useEffect(()=>{lo.isEqual(a,u.current)||(u.current=a,c.current=a,!lo.isEqual(a,s.current)&&n.actions.setRolesContent({content:a,flags:{touched:!1}}))},[n,a]),fe.useDidMountEffect(()=>{if(!(!t||!i.touched)&&!lo.isEqual(o,c.current))try{const d=JSON.stringify(o,null,2);t(d),c.current=o}catch(d){console.error("[Roles Editor Standalone] Error on value stringify:",d)}},[o,i.touched,t]),C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"relative h-screen z-10 overflow-hidden",children:C.jsx(xF,{...r})}),C.jsx(Kse,{})]})},Xse=e=>{const t=Toe();return C.jsx(vB,{adapter:t,children:C.jsx(fe.TipsProvider,{children:C.jsx(Yse,{...e})})})},Zse=({initialValue:e,...t})=>{const r=O.useMemo(()=>({...fe.sanitizeRoles(wF(e)),flags:{touched:!1}}),[e]);return C.jsx(Noe,{initialState:r,children:C.jsx(Xse,{initialValue:e,...t})})};exports.ROLES_EDITOR_SCOPE_CLASS=w2.ROLES_EDITOR_SCOPE_CLASS;exports.EditorStateAdapterProvider=vB;exports.Roles=xF;exports.Standalone=Zse;exports.jsonSchema=Gse;exports.useReduxAdapter=Yie;
114
114
  //# sourceMappingURL=index.cjs.js.map