@ws-ui/roles-editor 1.13.0-dev.5 → 1.13.0-dev.6
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
|
@@ -88,7 +88,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
88
88
|
`)+we+`return __p
|
|
89
89
|
}`;var We=IO(function(){return ot(F,Pe+"return "+we).apply(r,ee)});if(We.source=we,mh(We))throw We;return We}function E$(l){return ct(l).toLowerCase()}function _$(l){return ct(l).toUpperCase()}function O$(l,f,b){if(l=ct(l),l&&(b||f===r))return DE(l);if(!l||!(f=Qr(f)))return l;var R=Pn(l),k=Pn(f),F=jE(R,k),ee=qE(R,k)+1;return qi(R,F,ee).join("")}function C$(l,f,b){if(l=ct(l),l&&(b||f===r))return l.slice(0,LE(l)+1);if(!l||!(f=Qr(f)))return l;var R=Pn(l),k=qE(R,Pn(f))+1;return qi(R,0,k).join("")}function I$(l,f,b){if(l=ct(l),l&&(b||f===r))return l.replace(sr,"");if(!l||!(f=Qr(f)))return l;var R=Pn(l),k=jE(R,Pn(f));return qi(R,k).join("")}function R$(l,f){var b=j,R=W;if(Nt(f)){var k="separator"in f?f.separator:k;b="length"in f?He(f.length):b,R="omission"in f?Qr(f.omission):R}l=ct(l);var F=l.length;if(Wo(l)){var ee=Pn(l);F=ee.length}if(b>=F)return l;var oe=b-Uo(R);if(oe<1)return R;var ce=ee?qi(ee,0,oe).join(""):l.slice(0,oe);if(k===r)return ce+R;if(ee&&(oe+=ce.length-oe),bh(k)){if(l.slice(oe).search(k)){var me,be=ce;for(k.global||(k=Af(k.source,ct(Fo.exec(k))+"g")),k.lastIndex=0;me=k.exec(be);)var we=me.index;ce=ce.slice(0,we===r?oe:we)}}else if(l.indexOf(Qr(k),oe)!=oe){var _e=ce.lastIndexOf(k);_e>-1&&(ce=ce.slice(0,_e))}return ce+R}function N$(l){return l=ct(l),l&&fr.test(l)?l.replace(Mt,o7):l}var T$=Qo(function(l,f,b){return l+(b?" ":"")+f.toUpperCase()}),Sh=I_("toUpperCase");function CO(l,f,b){return l=ct(l),f=b?r:f,f===r?e7(l)?l7(l):WL(l):l.match(f)||[]}var IO=Ue(function(l,f){try{return Xr(l,r,f)}catch(b){return mh(b)?b:new Be(b)}}),P$=hi(function(l,f){return Zr(f,function(b){b=kn(b),Yn(l,b,vh(l[b],l))}),l});function M$(l){var f=l==null?0:l.length,b=De();return l=f?Ct(l,function(R){if(typeof R[1]!="function")throw new fn(a);return[b(R[0]),R[1]]}):[],Ue(function(R){for(var k=-1;++k<f;){var F=l[k];if(Xr(F[0],this,R))return Xr(F[1],this,R)}})}function k$(l){return o8(pn(l,p))}function Eh(l){return function(){return l}}function A$(l,f){return l==null||l!==l?f:l}var D$=N_(),j$=N_(!0);function jr(l){return l}function _h(l){return o_(typeof l=="function"?l:pn(l,p))}function q$(l){return s_(pn(l,p))}function z$(l,f){return l_(l,pn(f,p))}var L$=Ue(function(l,f){return function(b){return hs(b,l,f)}}),B$=Ue(function(l,f){return function(b){return hs(l,b,f)}});function Oh(l,f,b){var R=rr(f),k=fc(f,R);b==null&&!(Nt(f)&&(k.length||!R.length))&&(b=f,f=l,l=this,k=fc(f,rr(f)));var F=!(Nt(b)&&"chain"in b)||!!b.chain,ee=vi(l);return Zr(k,function(oe){var ce=f[oe];l[oe]=ce,ee&&(l.prototype[oe]=function(){var me=this.__chain__;if(F||me){var be=l(this.__wrapped__),we=be.__actions__=kr(this.__actions__);return we.push({func:ce,args:arguments,thisArg:l}),be.__chain__=me,be}return ce.apply(l,Pi([this.value()],arguments))})}),l}function F$(){return lr._===this&&(lr._=p7),this}function Ch(){}function $$(l){return l=He(l),Ue(function(f){return c_(f,l)})}var V$=rh(Ct),H$=rh(TE),W$=rh(If);function RO(l){return ch(l)?Rf(kn(l)):S8(l)}function U$(l){return function(f){return l==null?r:fo(l,f)}}var G$=P_(),K$=P_(!0);function Ih(){return[]}function Rh(){return!1}function Y$(){return{}}function X$(){return""}function Z$(){return!0}function J$(l,f){if(l=He(l),l<1||l>re)return[];var b=X,R=gr(l,X);f=De(f),l-=X;for(var k=Pf(R,f);++b<l;)f(b);return k}function Q$(l){return Ve(l)?Ct(l,kn):en(l)?[l]:kr(G_(ct(l)))}function eV(l){var f=++f7;return ct(l)+f}var tV=bc(function(l,f){return l+f},0),rV=nh("ceil"),nV=bc(function(l,f){return l/f},1),iV=nh("floor");function oV(l){return l&&l.length?dc(l,jr,$f):r}function aV(l,f){return l&&l.length?dc(l,De(f,2),$f):r}function sV(l){return kE(l,jr)}function lV(l,f){return kE(l,De(f,2))}function cV(l){return l&&l.length?dc(l,jr,Uf):r}function uV(l,f){return l&&l.length?dc(l,De(f,2),Uf):r}var dV=bc(function(l,f){return l*f},1),fV=nh("round"),hV=bc(function(l,f){return l-f},0);function pV(l){return l&&l.length?Tf(l,jr):0}function vV(l,f){return l&&l.length?Tf(l,De(f,2)):0}return L.after=zF,L.ary=iO,L.assign=O9,L.assignIn=bO,L.assignInWith=yO,L.assignWith=yh,L.at=C9,L.before=oO,L.bind=vh,L.bindAll=P$,L.bindKey=aO,L.castArray=XF,L.chain=tO,L.chunk=oB,L.compact=aB,L.concat=sB,L.cond=M$,L.conforms=k$,L.constant=Eh,L.countBy=vF,L.create=I9,L.curry=sO,L.curryRight=lO,L.debounce=cO,L.defaults=R9,L.defaultsDeep=N9,L.defer=LF,L.delay=BF,L.difference=lB,L.differenceBy=cB,L.differenceWith=uB,L.drop=dB,L.dropRight=fB,L.dropRightWhile=hB,L.dropWhile=pB,L.fill=vB,L.filter=mF,L.flatMap=xF,L.flatMapDeep=wF,L.flatMapDepth=SF,L.flatten=Z_,L.flattenDeep=gB,L.flattenDepth=mB,L.flip=FF,L.flow=D$,L.flowRight=j$,L.fromPairs=bB,L.functions=j9,L.functionsIn=q9,L.groupBy=EF,L.initial=xB,L.intersection=wB,L.intersectionBy=SB,L.intersectionWith=EB,L.invert=L9,L.invertBy=B9,L.invokeMap=OF,L.iteratee=_h,L.keyBy=CF,L.keys=rr,L.keysIn=Dr,L.map=Oc,L.mapKeys=$9,L.mapValues=V9,L.matches=q$,L.matchesProperty=z$,L.memoize=Ic,L.merge=H9,L.mergeWith=xO,L.method=L$,L.methodOf=B$,L.mixin=Oh,L.negate=Rc,L.nthArg=$$,L.omit=W9,L.omitBy=U9,L.once=$F,L.orderBy=IF,L.over=V$,L.overArgs=VF,L.overEvery=H$,L.overSome=W$,L.partial=gh,L.partialRight=uO,L.partition=RF,L.pick=G9,L.pickBy=wO,L.property=RO,L.propertyOf=U$,L.pull=IB,L.pullAll=Q_,L.pullAllBy=RB,L.pullAllWith=NB,L.pullAt=TB,L.range=G$,L.rangeRight=K$,L.rearg=HF,L.reject=PF,L.remove=PB,L.rest=WF,L.reverse=hh,L.sampleSize=kF,L.set=Y9,L.setWith=X9,L.shuffle=AF,L.slice=MB,L.sortBy=qF,L.sortedUniq=LB,L.sortedUniqBy=BB,L.split=y$,L.spread=UF,L.tail=FB,L.take=$B,L.takeRight=VB,L.takeRightWhile=HB,L.takeWhile=WB,L.tap=aF,L.throttle=GF,L.thru=_c,L.toArray=vO,L.toPairs=SO,L.toPairsIn=EO,L.toPath=Q$,L.toPlainObject=mO,L.transform=Z9,L.unary=KF,L.union=UB,L.unionBy=GB,L.unionWith=KB,L.uniq=YB,L.uniqBy=XB,L.uniqWith=ZB,L.unset=J9,L.unzip=ph,L.unzipWith=eO,L.update=Q9,L.updateWith=e$,L.values=ra,L.valuesIn=t$,L.without=JB,L.words=CO,L.wrap=YF,L.xor=QB,L.xorBy=eF,L.xorWith=tF,L.zip=rF,L.zipObject=nF,L.zipObjectDeep=iF,L.zipWith=oF,L.entries=SO,L.entriesIn=EO,L.extend=bO,L.extendWith=yO,Oh(L,L),L.add=tV,L.attempt=IO,L.camelCase=o$,L.capitalize=_O,L.ceil=rV,L.clamp=r$,L.clone=ZF,L.cloneDeep=QF,L.cloneDeepWith=e9,L.cloneWith=JF,L.conformsTo=t9,L.deburr=OO,L.defaultTo=A$,L.divide=nV,L.endsWith=a$,L.eq=An,L.escape=s$,L.escapeRegExp=l$,L.every=gF,L.find=bF,L.findIndex=Y_,L.findKey=T9,L.findLast=yF,L.findLastIndex=X_,L.findLastKey=P9,L.floor=iV,L.forEach=rO,L.forEachRight=nO,L.forIn=M9,L.forInRight=k9,L.forOwn=A9,L.forOwnRight=D9,L.get=xh,L.gt=r9,L.gte=n9,L.has=z9,L.hasIn=wh,L.head=J_,L.identity=jr,L.includes=_F,L.indexOf=yB,L.inRange=n$,L.invoke=F9,L.isArguments=vo,L.isArray=Ve,L.isArrayBuffer=i9,L.isArrayLike=Ar,L.isArrayLikeObject=Ft,L.isBoolean=o9,L.isBuffer=zi,L.isDate=a9,L.isElement=s9,L.isEmpty=l9,L.isEqual=c9,L.isEqualWith=u9,L.isError=mh,L.isFinite=d9,L.isFunction=vi,L.isInteger=dO,L.isLength=Nc,L.isMap=fO,L.isMatch=f9,L.isMatchWith=h9,L.isNaN=p9,L.isNative=v9,L.isNil=m9,L.isNull=g9,L.isNumber=hO,L.isObject=Nt,L.isObjectLike=Dt,L.isPlainObject=ys,L.isRegExp=bh,L.isSafeInteger=b9,L.isSet=pO,L.isString=Tc,L.isSymbol=en,L.isTypedArray=ta,L.isUndefined=y9,L.isWeakMap=x9,L.isWeakSet=w9,L.join=_B,L.kebabCase=c$,L.last=gn,L.lastIndexOf=OB,L.lowerCase=u$,L.lowerFirst=d$,L.lt=S9,L.lte=E9,L.max=oV,L.maxBy=aV,L.mean=sV,L.meanBy=lV,L.min=cV,L.minBy=uV,L.stubArray=Ih,L.stubFalse=Rh,L.stubObject=Y$,L.stubString=X$,L.stubTrue=Z$,L.multiply=dV,L.nth=CB,L.noConflict=F$,L.noop=Ch,L.now=Cc,L.pad=f$,L.padEnd=h$,L.padStart=p$,L.parseInt=v$,L.random=i$,L.reduce=NF,L.reduceRight=TF,L.repeat=g$,L.replace=m$,L.result=K9,L.round=fV,L.runInContext=se,L.sample=MF,L.size=DF,L.snakeCase=b$,L.some=jF,L.sortedIndex=kB,L.sortedIndexBy=AB,L.sortedIndexOf=DB,L.sortedLastIndex=jB,L.sortedLastIndexBy=qB,L.sortedLastIndexOf=zB,L.startCase=x$,L.startsWith=w$,L.subtract=hV,L.sum=pV,L.sumBy=vV,L.template=S$,L.times=J$,L.toFinite=gi,L.toInteger=He,L.toLength=gO,L.toLower=E$,L.toNumber=mn,L.toSafeInteger=_9,L.toString=ct,L.toUpper=_$,L.trim=O$,L.trimEnd=C$,L.trimStart=I$,L.truncate=R$,L.unescape=N$,L.uniqueId=eV,L.upperCase=T$,L.upperFirst=Sh,L.each=rO,L.eachRight=nO,L.first=J_,Oh(L,(function(){var l={};return Xn(L,function(f,b){lt.call(L.prototype,b)||(l[b]=f)}),l})(),{chain:!1}),L.VERSION=n,Zr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(l){L[l].placeholder=L}),Zr(["drop","take"],function(l,f){Qe.prototype[l]=function(b){b=b===r?1:Yt(He(b),0);var R=this.__filtered__&&!f?new Qe(this):this.clone();return R.__filtered__?R.__takeCount__=gr(b,R.__takeCount__):R.__views__.push({size:gr(b,X),type:l+(R.__dir__<0?"Right":"")}),R},Qe.prototype[l+"Right"]=function(b){return this.reverse()[l](b).reverse()}}),Zr(["filter","map","takeWhile"],function(l,f){var b=f+1,R=b==K||b==te;Qe.prototype[l]=function(k){var F=this.clone();return F.__iteratees__.push({iteratee:De(k,3),type:b}),F.__filtered__=F.__filtered__||R,F}}),Zr(["head","last"],function(l,f){var b="take"+(f?"Right":"");Qe.prototype[l]=function(){return this[b](1).value()[0]}}),Zr(["initial","tail"],function(l,f){var b="drop"+(f?"":"Right");Qe.prototype[l]=function(){return this.__filtered__?new Qe(this):this[b](1)}}),Qe.prototype.compact=function(){return this.filter(jr)},Qe.prototype.find=function(l){return this.filter(l).head()},Qe.prototype.findLast=function(l){return this.reverse().find(l)},Qe.prototype.invokeMap=Ue(function(l,f){return typeof l=="function"?new Qe(this):this.map(function(b){return hs(b,l,f)})}),Qe.prototype.reject=function(l){return this.filter(Rc(De(l)))},Qe.prototype.slice=function(l,f){l=He(l);var b=this;return b.__filtered__&&(l>0||f<0)?new Qe(b):(l<0?b=b.takeRight(-l):l&&(b=b.drop(l)),f!==r&&(f=He(f),b=f<0?b.dropRight(-f):b.take(f-l)),b)},Qe.prototype.takeRightWhile=function(l){return this.reverse().takeWhile(l).reverse()},Qe.prototype.toArray=function(){return this.take(X)},Xn(Qe.prototype,function(l,f){var b=/^(?:filter|find|map|reject)|While$/.test(f),R=/^(?:head|last)$/.test(f),k=L[R?"take"+(f=="last"?"Right":""):f],F=R||/^find/.test(f);k&&(L.prototype[f]=function(){var ee=this.__wrapped__,oe=R?[1]:arguments,ce=ee instanceof Qe,me=oe[0],be=ce||Ve(ee),we=function(Ye){var et=k.apply(L,Pi([Ye],oe));return R&&_e?et[0]:et};be&&b&&typeof me=="function"&&me.length!=1&&(ce=be=!1);var _e=this.__chain__,Pe=!!this.__actions__.length,qe=F&&!_e,We=ce&&!Pe;if(!F&&be){ee=We?ee:new Qe(this);var Ae=l.apply(ee,oe);return Ae.__actions__.push({func:_c,args:[we],thisArg:r}),new hn(Ae,_e)}return qe&&We?l.apply(this,oe):(Ae=this.thru(we),qe?R?Ae.value()[0]:Ae.value():Ae)})}),Zr(["pop","push","shift","sort","splice","unshift"],function(l){var f=Xl[l],b=/^(?:push|sort|unshift)$/.test(l)?"tap":"thru",R=/^(?:pop|shift)$/.test(l);L.prototype[l]=function(){var k=arguments;if(R&&!this.__chain__){var F=this.value();return f.apply(Ve(F)?F:[],k)}return this[b](function(ee){return f.apply(Ve(ee)?ee:[],k)})}}),Xn(Qe.prototype,function(l,f){var b=L[f];if(b){var R=b.name+"";lt.call(Xo,R)||(Xo[R]=[]),Xo[R].push({name:f,func:b})}}),Xo[mc(r,x).name]=[{name:"wrapper",func:r}],Qe.prototype.clone=T7,Qe.prototype.reverse=P7,Qe.prototype.value=M7,L.prototype.at=sF,L.prototype.chain=lF,L.prototype.commit=cF,L.prototype.next=uF,L.prototype.plant=fF,L.prototype.reverse=hF,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=pF,L.prototype.first=L.prototype.head,as&&(L.prototype[as]=dF),L}),Go=c7();ao?((ao.exports=Go)._=Go,Ef._=Go):lr._=Go}).call(uae)})(Xs,Xs.exports)),Xs.exports}var Xi=dae();function cz(e,t){const r=C.useRef([e]),n=C.useRef(0),i=C.useRef(!1),o=C.useRef(!1),[,a]=C.useReducer(u=>u+1,0);C.useEffect(()=>{if(i.current){i.current=!1;return}const u=n.current;if(Xi.isEqual(r.current[u],e)){o.current=!1;return}if(!o.current){r.current=[e],n.current=0,a();return}o.current=!1;const h=[...r.current.slice(0,u+1),e];r.current=h,n.current=h.length-1,a()},[e]);const s=C.useCallback(()=>{n.current<=0||(n.current-=1,i.current=!0,t(r.current[n.current]),a())},[t]),c=C.useCallback(()=>{n.current>=r.current.length-1||(n.current+=1,i.current=!0,t(r.current[n.current]),a())},[t]),d=C.useCallback(()=>{o.current=!0},[]);return{canUndo:n.current>0,canRedo:n.current<r.current.length-1,undo:s,redo:c,markEdit:d}}function fae(){const e=Ke.useAppDispatch(),t=Ke.useAppSelector(Ke.selectRoles),r=Ke.useAppSelector(Ke.selectPrivileges),n=Ke.useAppSelector(Ke.selectRolesFlags),i=Ke.useAppSelector(Ke.selectRolesAndPrivileges,(g,w)=>Xi.isEqual(g,w)),o=Ke.useAppSelector(Ke.selectCatalog),a=Ke.useAppSelector(Ke.selectQodly),s=Ke.useAppSelector(Ke.selectSelectedTab),c=Ke.useAppSelector(Ke.selectForceLogin),d=Ke.useAppSelector(Ke.selectRestrictedByDefault),u=Ke.useAppSelector(Ke.selectGuestPrivilege),h=Ke.useAppSelector(Ke.selectCatalogMethods),p=Ke.useAppSelector(Ke.selectDataclasses),v=Ke.useAppSelector(Ke.selectSingletons),y=C.useCallback(g=>{const{roles:w,privileges:x,forceLogin:_,restrictedByDefault:S}=pe.sanitizeRoles(g);e(Ke.updateRolesAndPrivileges({roles:w,privileges:x})),e(Ke.toggleForceLogin(_??!1)),e(Ke.toggleRestrictedByDefault(S??!1))},[e]),m=cz(i,y);return{getRoles:()=>t,getPrivileges:()=>r,getRolesFlags:()=>n,getRolesAndPrivileges:()=>i,getCatalog:()=>o,getQodly:()=>a,getSelectedTab:()=>s,getForceLogin:()=>c??!1,getRestrictedByDefault:()=>d??!1,getGuestPrivilege:()=>u??null,getCatalogMethods:()=>h,getDataclasses:()=>p,getSingletons:()=>v,getHost:()=>"web",getHistory:()=>({canUndo:m.canUndo,canRedo:m.canRedo}),actions:{updateRoles:g=>{m.markEdit(),e(Ke.updateRoles(g))},updatePrivileges:g=>{m.markEdit(),e(Ke.updatePrivileges(g))},setRolesContent:g=>{e(Ke.setRolesContent(g))},toggleTab:g=>{e(Ke.toggleTab(g))},toggleForceLogin:g=>{m.markEdit(),e(Ke.toggleForceLogin(g))},toggleRestrictedByDefault:g=>{m.markEdit(),e(Ke.toggleRestrictedByDefault(g))},setTabFlags:(g,w)=>{e(Ke.setTabFlags({path:g,flags:w}))},openModal:async g=>await e(Ke.openModal(g)).unwrap(),undo:m.undo,redo:m.redo}}}const uz=C.createContext(null),dz=({children:e,adapter:t})=>O.jsx(uz.Provider,{value:t,children:e}),Tr=()=>{const e=C.useContext(uz);if(!e)throw new Error("useEditorStateAdapter must be used within an EditorStateAdapterProvider");return e};var Zw=function(e,t){return Zw=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},Zw(e,t)};function jl(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Zw(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Jw(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Qw(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o}function e1(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function oi(e){return typeof e=="function"}function fz(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var M0=fz(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
90
90
|
`+r.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
91
|
-
`):"",this.name="UnsubscriptionError",this.errors=r}});function t1(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Zd=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,i,o;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var s=Jw(a),c=s.next();!c.done;c=s.next()){var d=c.value;d.remove(this)}}catch(m){t={error:m}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}else a.remove(this);var u=this.initialTeardown;if(oi(u))try{u()}catch(m){o=m instanceof M0?m.errors:[m]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var p=Jw(h),v=p.next();!v.done;v=p.next()){var y=v.value;try{L5(y)}catch(m){o=o??[],m instanceof M0?o=e1(e1([],Qw(o)),Qw(m.errors)):o.push(m)}}}catch(m){n={error:m}}finally{try{v&&!v.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}}if(o)throw new M0(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)L5(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&t1(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&t1(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),hz=Zd.EMPTY;function pz(e){return e instanceof Zd||e&&"closed"in e&&oi(e.remove)&&oi(e.add)&&oi(e.unsubscribe)}function L5(e){oi(e)?e():e.unsubscribe()}var hae={Promise:void 0},pae={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,e1([e,t],Qw(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function vae(e){pae.setTimeout(function(){throw e})}function B5(){}function Iu(e){e()}var GS=(function(e){jl(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,pz(r)&&r.add(n)):n.destination=bae,n}return t.create=function(r,n,i){return new r1(r,n,i)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(Zd),gae=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){iu(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){iu(n)}else iu(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){iu(r)}},e})(),r1=(function(e){jl(t,e);function t(r,n,i){var o=e.call(this)||this,a;return oi(r)||!r?a={next:r??void 0,error:n??void 0,complete:i??void 0}:a=r,o.destination=new gae(a),o}return t})(GS);function iu(e){vae(e)}function mae(e){throw e}var bae={closed:!0,next:B5,error:mae,complete:B5},yae=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function xae(e){return e}function wae(e){return e.length===0?xae:e.length===1?e[0]:function(r){return e.reduce(function(n,i){return i(n)},r)}}var F5=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var i=this,o=Eae(t)?t:new r1(t,r,n);return Iu(function(){var a=i,s=a.operator,c=a.source;o.add(s?s.call(o,c):c?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=$5(r),new r(function(i,o){var a=new r1({next:function(s){try{t(s)}catch(c){o(c),a.unsubscribe()}},error:o,complete:i});n.subscribe(a)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[yae]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return wae(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=$5(t),new t(function(n,i){var o;r.subscribe(function(a){return o=a},function(a){return i(a)},function(){return n(o)})})},e.create=function(t){return new e(t)},e})();function $5(e){var t;return(t=e??hae.Promise)!==null&&t!==void 0?t:Promise}function Sae(e){return e&&oi(e.next)&&oi(e.error)&&oi(e.complete)}function Eae(e){return e&&e instanceof GS||Sae(e)&&pz(e)}function _ae(e){return oi(e==null?void 0:e.lift)}function Oae(e){return function(t){if(_ae(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function Cae(e,t,r,n,i){return new Iae(e,t,r,n,i)}var Iae=(function(e){jl(t,e);function t(r,n,i,o,a,s){var c=e.call(this,r)||this;return c.onFinalize=a,c.shouldUnsubscribe=s,c._next=n?function(d){try{n(d)}catch(u){r.error(u)}}:e.prototype._next,c._error=o?function(d){try{o(d)}catch(u){r.error(u)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=i?function(){try{i()}catch(d){r.error(d)}finally{this.unsubscribe()}}:e.prototype._complete,c}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},t})(GS),Rae=fz(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),vz=(function(e){jl(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new V5(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new Rae},t.prototype.next=function(r){var n=this;Iu(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=Jw(n.currentObservers),s=a.next();!s.done;s=a.next()){var c=s.value;c.next(r)}}catch(d){i={error:d}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}}})},t.prototype.error=function(r){var n=this;Iu(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var i=n.observers;i.length;)i.shift().error(r)}})},t.prototype.complete=function(){var r=this;Iu(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,i=this,o=i.hasError,a=i.isStopped,s=i.observers;return o||a?hz:(this.currentObservers=null,s.push(r),new Zd(function(){n.currentObservers=null,t1(s,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,o=n.thrownError,a=n.isStopped;i?r.error(o):a&&r.complete()},t.prototype.asObservable=function(){var r=new F5;return r.source=this,r},t.create=function(r,n){return new V5(r,n)},t})(F5),V5=(function(e){jl(t,e);function t(r,n){var i=e.call(this)||this;return i.destination=r,i.source=n,i}return t.prototype.next=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,r)},t.prototype.error=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&i!==void 0?i:hz},t})(vz);function Nae(e,t){return Oae(function(r,n){var i=0;r.subscribe(Cae(n,function(o){return e.call(t,o,i++)&&n.next(o)}))})}var k0={},Ns={},ou={},H5;function gz(){if(H5)return ou;H5=1,Object.defineProperty(ou,"__esModule",{value:!0}),ou.default=r;let e;const t=new Uint8Array(16);function r(){if(!e&&(e=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!e))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(t)}return ou}var ua={},Ts={},Ps={},W5;function Tae(){if(W5)return Ps;W5=1,Object.defineProperty(Ps,"__esModule",{value:!0}),Ps.default=void 0;var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;return Ps.default=e,Ps}var U5;function Jd(){if(U5)return Ts;U5=1,Object.defineProperty(Ts,"__esModule",{value:!0}),Ts.default=void 0;var e=t(Tae());function t(i){return i&&i.__esModule?i:{default:i}}function r(i){return typeof i=="string"&&e.default.test(i)}var n=r;return Ts.default=n,Ts}var G5;function Qd(){if(G5)return ua;G5=1,Object.defineProperty(ua,"__esModule",{value:!0}),ua.default=void 0,ua.unsafeStringify=n;var e=t(Jd());function t(a){return a&&a.__esModule?a:{default:a}}const r=[];for(let a=0;a<256;++a)r.push((a+256).toString(16).slice(1));function n(a,s=0){return r[a[s+0]]+r[a[s+1]]+r[a[s+2]]+r[a[s+3]]+"-"+r[a[s+4]]+r[a[s+5]]+"-"+r[a[s+6]]+r[a[s+7]]+"-"+r[a[s+8]]+r[a[s+9]]+"-"+r[a[s+10]]+r[a[s+11]]+r[a[s+12]]+r[a[s+13]]+r[a[s+14]]+r[a[s+15]]}function i(a,s=0){const c=n(a,s);if(!(0,e.default)(c))throw TypeError("Stringified UUID is invalid");return c}var o=i;return ua.default=o,ua}var K5;function Pae(){if(K5)return Ns;K5=1,Object.defineProperty(Ns,"__esModule",{value:!0}),Ns.default=void 0;var e=r(gz()),t=Qd();function r(d){return d&&d.__esModule?d:{default:d}}let n,i,o=0,a=0;function s(d,u,h){let p=u&&h||0;const v=u||new Array(16);d=d||{};let y=d.node||n,m=d.clockseq!==void 0?d.clockseq:i;if(y==null||m==null){const E=d.random||(d.rng||e.default)();y==null&&(y=n=[E[0]|1,E[1],E[2],E[3],E[4],E[5]]),m==null&&(m=i=(E[6]<<8|E[7])&16383)}let g=d.msecs!==void 0?d.msecs:Date.now(),w=d.nsecs!==void 0?d.nsecs:a+1;const x=g-o+(w-a)/1e4;if(x<0&&d.clockseq===void 0&&(m=m+1&16383),(x<0||g>o)&&d.nsecs===void 0&&(w=0),w>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");o=g,a=w,i=m,g+=122192928e5;const _=((g&268435455)*1e4+w)%4294967296;v[p++]=_>>>24&255,v[p++]=_>>>16&255,v[p++]=_>>>8&255,v[p++]=_&255;const S=g/4294967296*1e4&268435455;v[p++]=S>>>8&255,v[p++]=S&255,v[p++]=S>>>24&15|16,v[p++]=S>>>16&255,v[p++]=m>>>8|128,v[p++]=m&255;for(let E=0;E<6;++E)v[p+E]=y[E];return u||(0,t.unsafeStringify)(v)}var c=s;return Ns.default=c,Ns}var Ms={},Hi={},ks={},Y5;function mz(){if(Y5)return ks;Y5=1,Object.defineProperty(ks,"__esModule",{value:!0}),ks.default=void 0;var e=t(Jd());function t(i){return i&&i.__esModule?i:{default:i}}function r(i){if(!(0,e.default)(i))throw TypeError("Invalid UUID");let o;const a=new Uint8Array(16);return a[0]=(o=parseInt(i.slice(0,8),16))>>>24,a[1]=o>>>16&255,a[2]=o>>>8&255,a[3]=o&255,a[4]=(o=parseInt(i.slice(9,13),16))>>>8,a[5]=o&255,a[6]=(o=parseInt(i.slice(14,18),16))>>>8,a[7]=o&255,a[8]=(o=parseInt(i.slice(19,23),16))>>>8,a[9]=o&255,a[10]=(o=parseInt(i.slice(24,36),16))/1099511627776&255,a[11]=o/4294967296&255,a[12]=o>>>24&255,a[13]=o>>>16&255,a[14]=o>>>8&255,a[15]=o&255,a}var n=r;return ks.default=n,ks}var X5;function bz(){if(X5)return Hi;X5=1,Object.defineProperty(Hi,"__esModule",{value:!0}),Hi.URL=Hi.DNS=void 0,Hi.default=a;var e=Qd(),t=r(mz());function r(s){return s&&s.__esModule?s:{default:s}}function n(s){s=unescape(encodeURIComponent(s));const c=[];for(let d=0;d<s.length;++d)c.push(s.charCodeAt(d));return c}const i="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Hi.DNS=i;const o="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Hi.URL=o;function a(s,c,d){function u(h,p,v,y){var m;if(typeof h=="string"&&(h=n(h)),typeof p=="string"&&(p=(0,t.default)(p)),((m=p)===null||m===void 0?void 0:m.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let g=new Uint8Array(16+h.length);if(g.set(p),g.set(h,p.length),g=d(g),g[6]=g[6]&15|c,g[8]=g[8]&63|128,v){y=y||0;for(let w=0;w<16;++w)v[y+w]=g[w];return v}return(0,e.unsafeStringify)(g)}try{u.name=s}catch{}return u.DNS=i,u.URL=o,u}return Hi}var As={},Z5;function Mae(){if(Z5)return As;Z5=1,Object.defineProperty(As,"__esModule",{value:!0}),As.default=void 0;function e(v){if(typeof v=="string"){const y=unescape(encodeURIComponent(v));v=new Uint8Array(y.length);for(let m=0;m<y.length;++m)v[m]=y.charCodeAt(m)}return t(n(i(v),v.length*8))}function t(v){const y=[],m=v.length*32,g="0123456789abcdef";for(let w=0;w<m;w+=8){const x=v[w>>5]>>>w%32&255,_=parseInt(g.charAt(x>>>4&15)+g.charAt(x&15),16);y.push(_)}return y}function r(v){return(v+64>>>9<<4)+14+1}function n(v,y){v[y>>5]|=128<<y%32,v[r(y)-1]=y;let m=1732584193,g=-271733879,w=-1732584194,x=271733878;for(let _=0;_<v.length;_+=16){const S=m,E=g,I=w,N=x;m=c(m,g,w,x,v[_],7,-680876936),x=c(x,m,g,w,v[_+1],12,-389564586),w=c(w,x,m,g,v[_+2],17,606105819),g=c(g,w,x,m,v[_+3],22,-1044525330),m=c(m,g,w,x,v[_+4],7,-176418897),x=c(x,m,g,w,v[_+5],12,1200080426),w=c(w,x,m,g,v[_+6],17,-1473231341),g=c(g,w,x,m,v[_+7],22,-45705983),m=c(m,g,w,x,v[_+8],7,1770035416),x=c(x,m,g,w,v[_+9],12,-1958414417),w=c(w,x,m,g,v[_+10],17,-42063),g=c(g,w,x,m,v[_+11],22,-1990404162),m=c(m,g,w,x,v[_+12],7,1804603682),x=c(x,m,g,w,v[_+13],12,-40341101),w=c(w,x,m,g,v[_+14],17,-1502002290),g=c(g,w,x,m,v[_+15],22,1236535329),m=d(m,g,w,x,v[_+1],5,-165796510),x=d(x,m,g,w,v[_+6],9,-1069501632),w=d(w,x,m,g,v[_+11],14,643717713),g=d(g,w,x,m,v[_],20,-373897302),m=d(m,g,w,x,v[_+5],5,-701558691),x=d(x,m,g,w,v[_+10],9,38016083),w=d(w,x,m,g,v[_+15],14,-660478335),g=d(g,w,x,m,v[_+4],20,-405537848),m=d(m,g,w,x,v[_+9],5,568446438),x=d(x,m,g,w,v[_+14],9,-1019803690),w=d(w,x,m,g,v[_+3],14,-187363961),g=d(g,w,x,m,v[_+8],20,1163531501),m=d(m,g,w,x,v[_+13],5,-1444681467),x=d(x,m,g,w,v[_+2],9,-51403784),w=d(w,x,m,g,v[_+7],14,1735328473),g=d(g,w,x,m,v[_+12],20,-1926607734),m=u(m,g,w,x,v[_+5],4,-378558),x=u(x,m,g,w,v[_+8],11,-2022574463),w=u(w,x,m,g,v[_+11],16,1839030562),g=u(g,w,x,m,v[_+14],23,-35309556),m=u(m,g,w,x,v[_+1],4,-1530992060),x=u(x,m,g,w,v[_+4],11,1272893353),w=u(w,x,m,g,v[_+7],16,-155497632),g=u(g,w,x,m,v[_+10],23,-1094730640),m=u(m,g,w,x,v[_+13],4,681279174),x=u(x,m,g,w,v[_],11,-358537222),w=u(w,x,m,g,v[_+3],16,-722521979),g=u(g,w,x,m,v[_+6],23,76029189),m=u(m,g,w,x,v[_+9],4,-640364487),x=u(x,m,g,w,v[_+12],11,-421815835),w=u(w,x,m,g,v[_+15],16,530742520),g=u(g,w,x,m,v[_+2],23,-995338651),m=h(m,g,w,x,v[_],6,-198630844),x=h(x,m,g,w,v[_+7],10,1126891415),w=h(w,x,m,g,v[_+14],15,-1416354905),g=h(g,w,x,m,v[_+5],21,-57434055),m=h(m,g,w,x,v[_+12],6,1700485571),x=h(x,m,g,w,v[_+3],10,-1894986606),w=h(w,x,m,g,v[_+10],15,-1051523),g=h(g,w,x,m,v[_+1],21,-2054922799),m=h(m,g,w,x,v[_+8],6,1873313359),x=h(x,m,g,w,v[_+15],10,-30611744),w=h(w,x,m,g,v[_+6],15,-1560198380),g=h(g,w,x,m,v[_+13],21,1309151649),m=h(m,g,w,x,v[_+4],6,-145523070),x=h(x,m,g,w,v[_+11],10,-1120210379),w=h(w,x,m,g,v[_+2],15,718787259),g=h(g,w,x,m,v[_+9],21,-343485551),m=o(m,S),g=o(g,E),w=o(w,I),x=o(x,N)}return[m,g,w,x]}function i(v){if(v.length===0)return[];const y=v.length*8,m=new Uint32Array(r(y));for(let g=0;g<y;g+=8)m[g>>5]|=(v[g/8]&255)<<g%32;return m}function o(v,y){const m=(v&65535)+(y&65535);return(v>>16)+(y>>16)+(m>>16)<<16|m&65535}function a(v,y){return v<<y|v>>>32-y}function s(v,y,m,g,w,x){return o(a(o(o(y,v),o(g,x)),w),m)}function c(v,y,m,g,w,x,_){return s(y&m|~y&g,v,y,w,x,_)}function d(v,y,m,g,w,x,_){return s(y&g|m&~g,v,y,w,x,_)}function u(v,y,m,g,w,x,_){return s(y^m^g,v,y,w,x,_)}function h(v,y,m,g,w,x,_){return s(m^(y|~g),v,y,w,x,_)}var p=e;return As.default=p,As}var J5;function kae(){if(J5)return Ms;J5=1,Object.defineProperty(Ms,"__esModule",{value:!0}),Ms.default=void 0;var e=r(bz()),t=r(Mae());function r(o){return o&&o.__esModule?o:{default:o}}var i=(0,e.default)("v3",48,t.default);return Ms.default=i,Ms}var Ds={},js={},Q5;function Aae(){if(Q5)return js;Q5=1,Object.defineProperty(js,"__esModule",{value:!0}),js.default=void 0;var t={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};return js.default=t,js}var eM;function Dae(){if(eM)return Ds;eM=1,Object.defineProperty(Ds,"__esModule",{value:!0}),Ds.default=void 0;var e=n(Aae()),t=n(gz()),r=Qd();function n(a){return a&&a.__esModule?a:{default:a}}function i(a,s,c){if(e.default.randomUUID&&!s&&!a)return e.default.randomUUID();a=a||{};const d=a.random||(a.rng||t.default)();if(d[6]=d[6]&15|64,d[8]=d[8]&63|128,s){c=c||0;for(let u=0;u<16;++u)s[c+u]=d[u];return s}return(0,r.unsafeStringify)(d)}var o=i;return Ds.default=o,Ds}var qs={},zs={},tM;function jae(){if(tM)return zs;tM=1,Object.defineProperty(zs,"__esModule",{value:!0}),zs.default=void 0;function e(i,o,a,s){switch(i){case 0:return o&a^~o&s;case 1:return o^a^s;case 2:return o&a^o&s^a&s;case 3:return o^a^s}}function t(i,o){return i<<o|i>>>32-o}function r(i){const o=[1518500249,1859775393,2400959708,3395469782],a=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof i=="string"){const u=unescape(encodeURIComponent(i));i=[];for(let h=0;h<u.length;++h)i.push(u.charCodeAt(h))}else Array.isArray(i)||(i=Array.prototype.slice.call(i));i.push(128);const s=i.length/4+2,c=Math.ceil(s/16),d=new Array(c);for(let u=0;u<c;++u){const h=new Uint32Array(16);for(let p=0;p<16;++p)h[p]=i[u*64+p*4]<<24|i[u*64+p*4+1]<<16|i[u*64+p*4+2]<<8|i[u*64+p*4+3];d[u]=h}d[c-1][14]=(i.length-1)*8/Math.pow(2,32),d[c-1][14]=Math.floor(d[c-1][14]),d[c-1][15]=(i.length-1)*8&4294967295;for(let u=0;u<c;++u){const h=new Uint32Array(80);for(let w=0;w<16;++w)h[w]=d[u][w];for(let w=16;w<80;++w)h[w]=t(h[w-3]^h[w-8]^h[w-14]^h[w-16],1);let p=a[0],v=a[1],y=a[2],m=a[3],g=a[4];for(let w=0;w<80;++w){const x=Math.floor(w/20),_=t(p,5)+e(x,v,y,m)+g+o[x]+h[w]>>>0;g=m,m=y,y=t(v,30)>>>0,v=p,p=_}a[0]=a[0]+p>>>0,a[1]=a[1]+v>>>0,a[2]=a[2]+y>>>0,a[3]=a[3]+m>>>0,a[4]=a[4]+g>>>0}return[a[0]>>24&255,a[0]>>16&255,a[0]>>8&255,a[0]&255,a[1]>>24&255,a[1]>>16&255,a[1]>>8&255,a[1]&255,a[2]>>24&255,a[2]>>16&255,a[2]>>8&255,a[2]&255,a[3]>>24&255,a[3]>>16&255,a[3]>>8&255,a[3]&255,a[4]>>24&255,a[4]>>16&255,a[4]>>8&255,a[4]&255]}var n=r;return zs.default=n,zs}var rM;function qae(){if(rM)return qs;rM=1,Object.defineProperty(qs,"__esModule",{value:!0}),qs.default=void 0;var e=r(bz()),t=r(jae());function r(o){return o&&o.__esModule?o:{default:o}}var i=(0,e.default)("v5",80,t.default);return qs.default=i,qs}var Ls={},nM;function zae(){if(nM)return Ls;nM=1,Object.defineProperty(Ls,"__esModule",{value:!0}),Ls.default=void 0;var e="00000000-0000-0000-0000-000000000000";return Ls.default=e,Ls}var Bs={},iM;function Lae(){if(iM)return Bs;iM=1,Object.defineProperty(Bs,"__esModule",{value:!0}),Bs.default=void 0;var e=t(Jd());function t(i){return i&&i.__esModule?i:{default:i}}function r(i){if(!(0,e.default)(i))throw TypeError("Invalid UUID");return parseInt(i.slice(14,15),16)}var n=r;return Bs.default=n,Bs}var oM;function Bae(){return oM||(oM=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return a.default}});var t=u(Pae()),r=u(kae()),n=u(Dae()),i=u(qae()),o=u(zae()),a=u(Lae()),s=u(Jd()),c=u(Qd()),d=u(mz());function u(h){return h&&h.__esModule?h:{default:h}}})(k0)),k0}var A0,aM;function Fae(){if(aM)return A0;aM=1;function e(t,r){if(!t||!r||!t.length||!r.length)throw new Error("Bad alphabet");this.srcAlphabet=t,this.dstAlphabet=r}return e.prototype.convert=function(t){var r,n,i,o={},a=this.srcAlphabet.length,s=this.dstAlphabet.length,c=t.length,d=typeof t=="string"?"":[];if(!this.isValid(t))throw new Error('Number "'+t+'" contains of non-alphabetic digits ('+this.srcAlphabet+")");if(this.srcAlphabet===this.dstAlphabet)return t;for(r=0;r<c;r++)o[r]=this.srcAlphabet.indexOf(t[r]);do{for(n=0,i=0,r=0;r<c;r++)n=n*a+o[r],n>=s?(o[i++]=parseInt(n/s,10),n=n%s):i>0&&(o[i++]=0);c=i,d=this.dstAlphabet.slice(n,n+1).concat(d)}while(i!==0);return d},e.prototype.isValid=function(t){for(var r=0;r<t.length;++r)if(this.srcAlphabet.indexOf(t[r])===-1)return!1;return!0},A0=e,A0}var D0,sM;function $ae(){if(sM)return D0;sM=1;var e=Fae();function t(r,n){var i=new e(r,n);return function(o){return i.convert(o)}}return t.BIN="01",t.OCT="01234567",t.DEC="0123456789",t.HEX="0123456789abcdef",D0=t,D0}var j0,lM;function Vae(){if(lM)return j0;lM=1;const{v4:e,validate:t}=Bae(),r=$ae(),n={cookieBase90:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~",flickrBase58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",uuid25Base36:"0123456789abcdefghijklmnopqrstuvwxyz"},i={consistentLength:!0};let o;const a=(d,u,h)=>{const p=u(d.toLowerCase().replace(/-/g,""));return!h||!h.consistentLength?p:p.padStart(h.shortIdLength,h.paddingChar)},s=(d,u)=>{const p=u(d).padStart(32,"0").match(/(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})/);return[p[1],p[2],p[3],p[4],p[5]].join("-")},c=d=>Math.ceil(Math.log(2**128)/Math.log(d));return j0=(()=>{const d=(u,h)=>{const p=u||n.flickrBase58,v={...i,...h};if([...new Set(Array.from(p))].length!==p.length)throw new Error("The provided Alphabet has duplicate characters resulting in unreliable results");const y=c(p.length),m={shortIdLength:y,consistentLength:v.consistentLength,paddingChar:p[0]},g=r(r.HEX,p),w=r(p,r.HEX),x=()=>a(e(),g,m),S={alphabet:p,fromUUID:E=>a(E,g,m),maxLength:y,generate:x,new:x,toUUID:E=>s(E,w),uuid:e,validate:(E,I=!1)=>{if(!E||typeof E!="string")return!1;const N=v.consistentLength?E.length===y:E.length<=y,T=E.split("").every(M=>p.includes(M));return I===!1?N&&T:N&&T&&t(s(E,w))}};return Object.freeze(S),S};return d.constants=n,d.uuid=e,d.generate=()=>(o||(o=d(n.flickrBase58).generate),o()),d})(),j0}var yz=Vae();const xz=new vz;function Hae(e,t){switch(t.type){case"UPDATE_ROLES":return{...e,roles:t.payload,flags:{...e.flags,touched:!0}};case"UPDATE_PRIVILEGES":return{...e,privileges:t.payload,flags:{...e.flags,touched:!0}};case"SET_ROLES_CONTENT":{const{content:r,flags:n={},...i}=t.payload,o=pe.sanitizeRoles(r),a={...e.flags,...n};return{...e,...o,...i,flags:a}}case"TOGGLE_TAB":return{...e,selectedTab:t.payload};case"TOGGLE_FORCE_LOGIN":return e.forceLogin===t.payload?e:{...e,forceLogin:t.payload,flags:{...e.flags,touched:!0}};case"TOGGLE_RESTRICTED_BY_DEFAULT":return e.restrictedByDefault===t.payload?e:{...e,restrictedByDefault:t.payload,flags:{...e.flags,touched:!0}};case"SET_FLAGS":return{...e,flags:{...e.flags,...t.payload}};case"CREATE_MODAL":return{...e,modals:{...e.modals,list:[...e.modals.list,t.payload]}};case"REMOVE_MODAL":return{...e,modals:{...e.modals,list:e.modals.list.filter(r=>r.id!==t.payload)}};case"CLOSE_MODAL":{const{id:r,reason:n}=t.payload;let i;if(n)if(e.modals.list.find(a=>a.id===r))i={...e,modals:{...e.modals,list:e.modals.list.map(a=>a.id===r?{...a,closeReason:n,isOpen:!1}:a)}};else return e;else i={...e,modals:{...e.modals,list:e.modals.list.filter(o=>o.id!==r)}};return xz.next(i.modals),i}case"EDIT_MODAL":{const{id:r,...n}=t.payload;return e.modals.list.find(o=>o.id===r)?{...e,modals:{...e.modals,list:e.modals.list.map(o=>o.id===r?{...o,...n}:o)}}:e}default:return e}}const KS=C.createContext(null),Wae=()=>({roles:{},privileges:{},flags:{touched:!1},date:void 0,selectedTab:"roles",forceLogin:!1,restrictedByDefault:!1,modals:{list:[]}}),Uae=({children:e,catalog:t=null,qodly:r=!1,host:n,onSetTabFlags:i,history:o,initialState:a})=>{const[s,c]=C.useReducer(Hae,{...Wae(),...a}),d=C.useMemo(()=>t?pe.parseCatalog(t):null,[t]),u=C.useMemo(()=>({catalog:d,qodly:r,host:n,onSetTabFlags:i,history:o}),[d,r,n,i,o]);return O.jsx(KS.Provider,{value:{state:s,dispatch:c,external:u},children:e})};function Gae(){var s,c,d,u;const e=C.useContext(KS);if(!e)throw new Error("useReducerAdapter must be used within a ReducerAdapterProvider");const{state:t,dispatch:r,external:n}=e,i=C.useMemo(()=>pe.rolesToAPI({roles:t.roles,privileges:t.privileges,forceLogin:t.forceLogin,restrictedByDefault:t.restrictedByDefault}),[t.roles,t.privileges,t.forceLogin,t.restrictedByDefault]),o=C.useCallback(h=>{const{roles:p,privileges:v,forceLogin:y,restrictedByDefault:m}=pe.sanitizeRoles(h);r({type:"UPDATE_ROLES",payload:p}),r({type:"UPDATE_PRIVILEGES",payload:v}),r({type:"TOGGLE_FORCE_LOGIN",payload:y??!1}),r({type:"TOGGLE_RESTRICTED_BY_DEFAULT",payload:m??!1})},[r]),a=cz(i,o);return{getRoles:C.useCallback(()=>t.roles,[t.roles]),getPrivileges:C.useCallback(()=>t.privileges,[t.privileges]),getRolesFlags:C.useCallback(()=>t.flags,[t.flags]),getRolesAndPrivileges:C.useCallback(()=>i,[i]),getCatalog:C.useCallback(()=>n.catalog??null,[n.catalog]),getQodly:C.useCallback(()=>n.qodly??!1,[n.qodly]),getSelectedTab:C.useCallback(()=>t.selectedTab,[t.selectedTab]),getForceLogin:C.useCallback(()=>t.forceLogin??!1,[t.forceLogin]),getRestrictedByDefault:C.useCallback(()=>t.restrictedByDefault??!1,[t.restrictedByDefault]),getGuestPrivilege:C.useCallback(()=>Object.values(t.privileges).find(({privilege:h})=>h==="guest")??null,[t.privileges]),getCatalogMethods:C.useCallback(()=>{var h;return((h=n.catalog)==null?void 0:h.methods)??[]},[n.catalog]),getDataclasses:C.useCallback(()=>{var h;return((h=n.catalog)==null?void 0:h.dataClasses)??{}},[n.catalog]),getSingletons:C.useCallback(()=>{var h;return((h=n.catalog)==null?void 0:h.singletons)??{}},[n.catalog]),getHost:C.useCallback(()=>n.host??"web",[n.host]),getHistory:C.useCallback(()=>{var h,p;return{canUndo:((h=n.history)==null?void 0:h.canUndo)??a.canUndo,canRedo:((p=n.history)==null?void 0:p.canRedo)??a.canRedo}},[a.canUndo,a.canRedo,(s=n.history)==null?void 0:s.canUndo,(c=n.history)==null?void 0:c.canRedo]),actions:{updateRoles:C.useCallback(h=>{a.markEdit(),r({type:"UPDATE_ROLES",payload:h})},[a.markEdit]),updatePrivileges:C.useCallback(h=>{a.markEdit(),r({type:"UPDATE_PRIVILEGES",payload:h})},[a.markEdit]),setRolesContent:C.useCallback(h=>{r({type:"SET_ROLES_CONTENT",payload:h})},[]),toggleTab:C.useCallback(h=>{r({type:"TOGGLE_TAB",payload:h})},[]),toggleForceLogin:C.useCallback(h=>{a.markEdit(),r({type:"TOGGLE_FORCE_LOGIN",payload:h})},[a.markEdit]),toggleRestrictedByDefault:C.useCallback(h=>{a.markEdit(),r({type:"TOGGLE_RESTRICTED_BY_DEFAULT",payload:h})},[a.markEdit]),setTabFlags:C.useCallback((h,p)=>{n.onSetTabFlags&&n.onSetTabFlags(h,p)},[n.onSetTabFlags]),openModal:C.useCallback(async h=>{const{type:p=pe.ModalType.ALERT}=h,v=yz.generate();return r({type:"CREATE_MODAL",payload:{id:v,type:p,isOpen:!0,...h}}),p===pe.ModalType.CONFIRM?new Promise(y=>{const m=xz.pipe(Nae(g=>{const w=g.list.find(x=>x.id===v);return w!==void 0&&!w.isOpen})).subscribe(g=>{var x;const w=g.list.find(_=>_.id===v);if(w){const _=w.closeReason===pe.ModalCloseReason.CONFIRMED,S=Xi.entries(((x=w.views)==null?void 0:x.toggles)||{}).reduce((E,I)=>({...E,[I[0]]:I[1].value}),{});r({type:"REMOVE_MODAL",payload:v}),m.unsubscribe(),y({confirmed:_,options:S})}})}):{confirmed:!1}},[r]),undo:C.useCallback(()=>{var h;if((h=n.history)!=null&&h.onUndo){n.history.onUndo();return}a.undo()},[(d=n.history)==null?void 0:d.onUndo,a.undo]),redo:C.useCallback(()=>{var h;if((h=n.history)!=null&&h.onRedo){n.history.onRedo();return}a.redo()},[(u=n.history)==null?void 0:u.onRedo,a.redo])}}}function Kae(){const e=C.useContext(KS);if(!e)throw new Error("useModals must be used within a ReducerAdapterProvider");const{state:t,dispatch:r}=e;return{modals:t.modals.list,closeModal:C.useCallback(n=>{r({type:"CLOSE_MODAL",payload:n})},[r]),editModal:C.useCallback(n=>{r({type:"EDIT_MODAL",payload:n})},[r]),removeModal:C.useCallback(n=>{r({type:"REMOVE_MODAL",payload:n})},[r])}}const q0=({child:e,parent:t,status:r})=>{const n=Tr(),i=n.getPrivileges();function o(){const s=pe.addPrivilegeIn(t.id,e.id,i);n.actions.updatePrivileges(s)}function a(){const s=pe.removePrivilegeFrom(t.id,e.id,i);n.actions.updatePrivileges(s)}return O.jsxs(vu,{color:r==="included"?"primary":"dark",onClick:r==="included"?a:o,disabled:r==="disabled",children:[e.privilege,O.jsx(ja,{className:an("transform transition-transform",{"rotate-45":r==="included"})})]})},Yae=({selectedPrivilege:e,privileges:t,onSelect:r,setShowIncluded:n,showIncluded:i})=>{const o=Object.values(t),a=pe.getPrivilegeById(e.id,t);let s=a?pe.populateShallow(a.includes,t):[],c=a?pe.populateShallow(pe.parents(a.id,t),t):[],d=a?pe.populateShallow(pe.allowed(a.id,t),t):[];return[s,c,d]=[s,c,d].map(u=>u.filter(h=>(h==null?void 0:h.privilege)!=="guest")),o.length<2&&s.length+c.length+d.length===0?null:O.jsxs(br,{depth:1,className:"w-full border-b p-4",children:[O.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[" ",o.length>2?O.jsx("h4",{className:"text-[13px] font-semibold",children:"Include a privilege"}):O.jsx("div",{}),O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx(Fu,{onChange:()=>n(!i),checked:i}),O.jsx("label",{className:"text-xs",children:" Show inherited permissions"})]})]}),O.jsxs("div",{className:"flex flex-wrap items-start justify-start gap-1",children:[s.map(u=>O.jsx(q0,{child:u,parent:e,status:"included",onSelect:r,currentPrivilegeId:u.id},u.id)),d.map(u=>O.jsx(q0,{child:u,parent:e,status:"available",onSelect:r,currentPrivilegeId:u.id},u.id)),c.map(u=>O.jsx(q0,{child:u,parent:e,status:"disabled",onSelect:r,currentPrivilegeId:u.id},u.id))]})]})};function da(e,t,r){let n=r.initialDeps??[],i,o=!0;function a(){var s,c,d;let u;r.key&&((s=r.debug)!=null&&s.call(r))&&(u=Date.now());const h=e();if(!(h.length!==n.length||h.some((y,m)=>n[m]!==y)))return i;n=h;let v;if(r.key&&((c=r.debug)!=null&&c.call(r))&&(v=Date.now()),i=t(...h),r.key&&((d=r.debug)!=null&&d.call(r))){const y=Math.round((Date.now()-u)*100)/100,m=Math.round((Date.now()-v)*100)/100,g=m/16,w=(x,_)=>{for(x=String(x);x.length<_;)x=" "+x;return x};console.info(`%c⏱ ${w(m,5)} /${w(y,5)} ms`,`
|
|
91
|
+
`):"",this.name="UnsubscriptionError",this.errors=r}});function t1(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Zd=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,i,o;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var s=Jw(a),c=s.next();!c.done;c=s.next()){var d=c.value;d.remove(this)}}catch(m){t={error:m}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}else a.remove(this);var u=this.initialTeardown;if(oi(u))try{u()}catch(m){o=m instanceof M0?m.errors:[m]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var p=Jw(h),v=p.next();!v.done;v=p.next()){var y=v.value;try{L5(y)}catch(m){o=o??[],m instanceof M0?o=e1(e1([],Qw(o)),Qw(m.errors)):o.push(m)}}}catch(m){n={error:m}}finally{try{v&&!v.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}}if(o)throw new M0(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)L5(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&t1(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&t1(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),hz=Zd.EMPTY;function pz(e){return e instanceof Zd||e&&"closed"in e&&oi(e.remove)&&oi(e.add)&&oi(e.unsubscribe)}function L5(e){oi(e)?e():e.unsubscribe()}var hae={Promise:void 0},pae={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,e1([e,t],Qw(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function vae(e){pae.setTimeout(function(){throw e})}function B5(){}function Iu(e){e()}var GS=(function(e){jl(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,pz(r)&&r.add(n)):n.destination=bae,n}return t.create=function(r,n,i){return new r1(r,n,i)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(Zd),gae=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){iu(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){iu(n)}else iu(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){iu(r)}},e})(),r1=(function(e){jl(t,e);function t(r,n,i){var o=e.call(this)||this,a;return oi(r)||!r?a={next:r??void 0,error:n??void 0,complete:i??void 0}:a=r,o.destination=new gae(a),o}return t})(GS);function iu(e){vae(e)}function mae(e){throw e}var bae={closed:!0,next:B5,error:mae,complete:B5},yae=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function xae(e){return e}function wae(e){return e.length===0?xae:e.length===1?e[0]:function(r){return e.reduce(function(n,i){return i(n)},r)}}var F5=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var i=this,o=Eae(t)?t:new r1(t,r,n);return Iu(function(){var a=i,s=a.operator,c=a.source;o.add(s?s.call(o,c):c?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=$5(r),new r(function(i,o){var a=new r1({next:function(s){try{t(s)}catch(c){o(c),a.unsubscribe()}},error:o,complete:i});n.subscribe(a)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[yae]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return wae(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=$5(t),new t(function(n,i){var o;r.subscribe(function(a){return o=a},function(a){return i(a)},function(){return n(o)})})},e.create=function(t){return new e(t)},e})();function $5(e){var t;return(t=e??hae.Promise)!==null&&t!==void 0?t:Promise}function Sae(e){return e&&oi(e.next)&&oi(e.error)&&oi(e.complete)}function Eae(e){return e&&e instanceof GS||Sae(e)&&pz(e)}function _ae(e){return oi(e==null?void 0:e.lift)}function Oae(e){return function(t){if(_ae(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function Cae(e,t,r,n,i){return new Iae(e,t,r,n,i)}var Iae=(function(e){jl(t,e);function t(r,n,i,o,a,s){var c=e.call(this,r)||this;return c.onFinalize=a,c.shouldUnsubscribe=s,c._next=n?function(d){try{n(d)}catch(u){r.error(u)}}:e.prototype._next,c._error=o?function(d){try{o(d)}catch(u){r.error(u)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=i?function(){try{i()}catch(d){r.error(d)}finally{this.unsubscribe()}}:e.prototype._complete,c}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},t})(GS),Rae=fz(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),vz=(function(e){jl(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new V5(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new Rae},t.prototype.next=function(r){var n=this;Iu(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=Jw(n.currentObservers),s=a.next();!s.done;s=a.next()){var c=s.value;c.next(r)}}catch(d){i={error:d}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}}})},t.prototype.error=function(r){var n=this;Iu(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var i=n.observers;i.length;)i.shift().error(r)}})},t.prototype.complete=function(){var r=this;Iu(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,i=this,o=i.hasError,a=i.isStopped,s=i.observers;return o||a?hz:(this.currentObservers=null,s.push(r),new Zd(function(){n.currentObservers=null,t1(s,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,o=n.thrownError,a=n.isStopped;i?r.error(o):a&&r.complete()},t.prototype.asObservable=function(){var r=new F5;return r.source=this,r},t.create=function(r,n){return new V5(r,n)},t})(F5),V5=(function(e){jl(t,e);function t(r,n){var i=e.call(this)||this;return i.destination=r,i.source=n,i}return t.prototype.next=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,r)},t.prototype.error=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&i!==void 0?i:hz},t})(vz);function Nae(e,t){return Oae(function(r,n){var i=0;r.subscribe(Cae(n,function(o){return e.call(t,o,i++)&&n.next(o)}))})}var k0={},Ns={},ou={},H5;function gz(){if(H5)return ou;H5=1,Object.defineProperty(ou,"__esModule",{value:!0}),ou.default=r;let e;const t=new Uint8Array(16);function r(){if(!e&&(e=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!e))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(t)}return ou}var ua={},Ts={},Ps={},W5;function Tae(){if(W5)return Ps;W5=1,Object.defineProperty(Ps,"__esModule",{value:!0}),Ps.default=void 0;var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;return Ps.default=e,Ps}var U5;function Jd(){if(U5)return Ts;U5=1,Object.defineProperty(Ts,"__esModule",{value:!0}),Ts.default=void 0;var e=t(Tae());function t(i){return i&&i.__esModule?i:{default:i}}function r(i){return typeof i=="string"&&e.default.test(i)}var n=r;return Ts.default=n,Ts}var G5;function Qd(){if(G5)return ua;G5=1,Object.defineProperty(ua,"__esModule",{value:!0}),ua.default=void 0,ua.unsafeStringify=n;var e=t(Jd());function t(a){return a&&a.__esModule?a:{default:a}}const r=[];for(let a=0;a<256;++a)r.push((a+256).toString(16).slice(1));function n(a,s=0){return r[a[s+0]]+r[a[s+1]]+r[a[s+2]]+r[a[s+3]]+"-"+r[a[s+4]]+r[a[s+5]]+"-"+r[a[s+6]]+r[a[s+7]]+"-"+r[a[s+8]]+r[a[s+9]]+"-"+r[a[s+10]]+r[a[s+11]]+r[a[s+12]]+r[a[s+13]]+r[a[s+14]]+r[a[s+15]]}function i(a,s=0){const c=n(a,s);if(!(0,e.default)(c))throw TypeError("Stringified UUID is invalid");return c}var o=i;return ua.default=o,ua}var K5;function Pae(){if(K5)return Ns;K5=1,Object.defineProperty(Ns,"__esModule",{value:!0}),Ns.default=void 0;var e=r(gz()),t=Qd();function r(d){return d&&d.__esModule?d:{default:d}}let n,i,o=0,a=0;function s(d,u,h){let p=u&&h||0;const v=u||new Array(16);d=d||{};let y=d.node||n,m=d.clockseq!==void 0?d.clockseq:i;if(y==null||m==null){const E=d.random||(d.rng||e.default)();y==null&&(y=n=[E[0]|1,E[1],E[2],E[3],E[4],E[5]]),m==null&&(m=i=(E[6]<<8|E[7])&16383)}let g=d.msecs!==void 0?d.msecs:Date.now(),w=d.nsecs!==void 0?d.nsecs:a+1;const x=g-o+(w-a)/1e4;if(x<0&&d.clockseq===void 0&&(m=m+1&16383),(x<0||g>o)&&d.nsecs===void 0&&(w=0),w>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");o=g,a=w,i=m,g+=122192928e5;const _=((g&268435455)*1e4+w)%4294967296;v[p++]=_>>>24&255,v[p++]=_>>>16&255,v[p++]=_>>>8&255,v[p++]=_&255;const S=g/4294967296*1e4&268435455;v[p++]=S>>>8&255,v[p++]=S&255,v[p++]=S>>>24&15|16,v[p++]=S>>>16&255,v[p++]=m>>>8|128,v[p++]=m&255;for(let E=0;E<6;++E)v[p+E]=y[E];return u||(0,t.unsafeStringify)(v)}var c=s;return Ns.default=c,Ns}var Ms={},Hi={},ks={},Y5;function mz(){if(Y5)return ks;Y5=1,Object.defineProperty(ks,"__esModule",{value:!0}),ks.default=void 0;var e=t(Jd());function t(i){return i&&i.__esModule?i:{default:i}}function r(i){if(!(0,e.default)(i))throw TypeError("Invalid UUID");let o;const a=new Uint8Array(16);return a[0]=(o=parseInt(i.slice(0,8),16))>>>24,a[1]=o>>>16&255,a[2]=o>>>8&255,a[3]=o&255,a[4]=(o=parseInt(i.slice(9,13),16))>>>8,a[5]=o&255,a[6]=(o=parseInt(i.slice(14,18),16))>>>8,a[7]=o&255,a[8]=(o=parseInt(i.slice(19,23),16))>>>8,a[9]=o&255,a[10]=(o=parseInt(i.slice(24,36),16))/1099511627776&255,a[11]=o/4294967296&255,a[12]=o>>>24&255,a[13]=o>>>16&255,a[14]=o>>>8&255,a[15]=o&255,a}var n=r;return ks.default=n,ks}var X5;function bz(){if(X5)return Hi;X5=1,Object.defineProperty(Hi,"__esModule",{value:!0}),Hi.URL=Hi.DNS=void 0,Hi.default=a;var e=Qd(),t=r(mz());function r(s){return s&&s.__esModule?s:{default:s}}function n(s){s=unescape(encodeURIComponent(s));const c=[];for(let d=0;d<s.length;++d)c.push(s.charCodeAt(d));return c}const i="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Hi.DNS=i;const o="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Hi.URL=o;function a(s,c,d){function u(h,p,v,y){var m;if(typeof h=="string"&&(h=n(h)),typeof p=="string"&&(p=(0,t.default)(p)),((m=p)===null||m===void 0?void 0:m.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let g=new Uint8Array(16+h.length);if(g.set(p),g.set(h,p.length),g=d(g),g[6]=g[6]&15|c,g[8]=g[8]&63|128,v){y=y||0;for(let w=0;w<16;++w)v[y+w]=g[w];return v}return(0,e.unsafeStringify)(g)}try{u.name=s}catch{}return u.DNS=i,u.URL=o,u}return Hi}var As={},Z5;function Mae(){if(Z5)return As;Z5=1,Object.defineProperty(As,"__esModule",{value:!0}),As.default=void 0;function e(v){if(typeof v=="string"){const y=unescape(encodeURIComponent(v));v=new Uint8Array(y.length);for(let m=0;m<y.length;++m)v[m]=y.charCodeAt(m)}return t(n(i(v),v.length*8))}function t(v){const y=[],m=v.length*32,g="0123456789abcdef";for(let w=0;w<m;w+=8){const x=v[w>>5]>>>w%32&255,_=parseInt(g.charAt(x>>>4&15)+g.charAt(x&15),16);y.push(_)}return y}function r(v){return(v+64>>>9<<4)+14+1}function n(v,y){v[y>>5]|=128<<y%32,v[r(y)-1]=y;let m=1732584193,g=-271733879,w=-1732584194,x=271733878;for(let _=0;_<v.length;_+=16){const S=m,E=g,I=w,N=x;m=c(m,g,w,x,v[_],7,-680876936),x=c(x,m,g,w,v[_+1],12,-389564586),w=c(w,x,m,g,v[_+2],17,606105819),g=c(g,w,x,m,v[_+3],22,-1044525330),m=c(m,g,w,x,v[_+4],7,-176418897),x=c(x,m,g,w,v[_+5],12,1200080426),w=c(w,x,m,g,v[_+6],17,-1473231341),g=c(g,w,x,m,v[_+7],22,-45705983),m=c(m,g,w,x,v[_+8],7,1770035416),x=c(x,m,g,w,v[_+9],12,-1958414417),w=c(w,x,m,g,v[_+10],17,-42063),g=c(g,w,x,m,v[_+11],22,-1990404162),m=c(m,g,w,x,v[_+12],7,1804603682),x=c(x,m,g,w,v[_+13],12,-40341101),w=c(w,x,m,g,v[_+14],17,-1502002290),g=c(g,w,x,m,v[_+15],22,1236535329),m=d(m,g,w,x,v[_+1],5,-165796510),x=d(x,m,g,w,v[_+6],9,-1069501632),w=d(w,x,m,g,v[_+11],14,643717713),g=d(g,w,x,m,v[_],20,-373897302),m=d(m,g,w,x,v[_+5],5,-701558691),x=d(x,m,g,w,v[_+10],9,38016083),w=d(w,x,m,g,v[_+15],14,-660478335),g=d(g,w,x,m,v[_+4],20,-405537848),m=d(m,g,w,x,v[_+9],5,568446438),x=d(x,m,g,w,v[_+14],9,-1019803690),w=d(w,x,m,g,v[_+3],14,-187363961),g=d(g,w,x,m,v[_+8],20,1163531501),m=d(m,g,w,x,v[_+13],5,-1444681467),x=d(x,m,g,w,v[_+2],9,-51403784),w=d(w,x,m,g,v[_+7],14,1735328473),g=d(g,w,x,m,v[_+12],20,-1926607734),m=u(m,g,w,x,v[_+5],4,-378558),x=u(x,m,g,w,v[_+8],11,-2022574463),w=u(w,x,m,g,v[_+11],16,1839030562),g=u(g,w,x,m,v[_+14],23,-35309556),m=u(m,g,w,x,v[_+1],4,-1530992060),x=u(x,m,g,w,v[_+4],11,1272893353),w=u(w,x,m,g,v[_+7],16,-155497632),g=u(g,w,x,m,v[_+10],23,-1094730640),m=u(m,g,w,x,v[_+13],4,681279174),x=u(x,m,g,w,v[_],11,-358537222),w=u(w,x,m,g,v[_+3],16,-722521979),g=u(g,w,x,m,v[_+6],23,76029189),m=u(m,g,w,x,v[_+9],4,-640364487),x=u(x,m,g,w,v[_+12],11,-421815835),w=u(w,x,m,g,v[_+15],16,530742520),g=u(g,w,x,m,v[_+2],23,-995338651),m=h(m,g,w,x,v[_],6,-198630844),x=h(x,m,g,w,v[_+7],10,1126891415),w=h(w,x,m,g,v[_+14],15,-1416354905),g=h(g,w,x,m,v[_+5],21,-57434055),m=h(m,g,w,x,v[_+12],6,1700485571),x=h(x,m,g,w,v[_+3],10,-1894986606),w=h(w,x,m,g,v[_+10],15,-1051523),g=h(g,w,x,m,v[_+1],21,-2054922799),m=h(m,g,w,x,v[_+8],6,1873313359),x=h(x,m,g,w,v[_+15],10,-30611744),w=h(w,x,m,g,v[_+6],15,-1560198380),g=h(g,w,x,m,v[_+13],21,1309151649),m=h(m,g,w,x,v[_+4],6,-145523070),x=h(x,m,g,w,v[_+11],10,-1120210379),w=h(w,x,m,g,v[_+2],15,718787259),g=h(g,w,x,m,v[_+9],21,-343485551),m=o(m,S),g=o(g,E),w=o(w,I),x=o(x,N)}return[m,g,w,x]}function i(v){if(v.length===0)return[];const y=v.length*8,m=new Uint32Array(r(y));for(let g=0;g<y;g+=8)m[g>>5]|=(v[g/8]&255)<<g%32;return m}function o(v,y){const m=(v&65535)+(y&65535);return(v>>16)+(y>>16)+(m>>16)<<16|m&65535}function a(v,y){return v<<y|v>>>32-y}function s(v,y,m,g,w,x){return o(a(o(o(y,v),o(g,x)),w),m)}function c(v,y,m,g,w,x,_){return s(y&m|~y&g,v,y,w,x,_)}function d(v,y,m,g,w,x,_){return s(y&g|m&~g,v,y,w,x,_)}function u(v,y,m,g,w,x,_){return s(y^m^g,v,y,w,x,_)}function h(v,y,m,g,w,x,_){return s(m^(y|~g),v,y,w,x,_)}var p=e;return As.default=p,As}var J5;function kae(){if(J5)return Ms;J5=1,Object.defineProperty(Ms,"__esModule",{value:!0}),Ms.default=void 0;var e=r(bz()),t=r(Mae());function r(o){return o&&o.__esModule?o:{default:o}}var i=(0,e.default)("v3",48,t.default);return Ms.default=i,Ms}var Ds={},js={},Q5;function Aae(){if(Q5)return js;Q5=1,Object.defineProperty(js,"__esModule",{value:!0}),js.default=void 0;var t={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};return js.default=t,js}var eM;function Dae(){if(eM)return Ds;eM=1,Object.defineProperty(Ds,"__esModule",{value:!0}),Ds.default=void 0;var e=n(Aae()),t=n(gz()),r=Qd();function n(a){return a&&a.__esModule?a:{default:a}}function i(a,s,c){if(e.default.randomUUID&&!s&&!a)return e.default.randomUUID();a=a||{};const d=a.random||(a.rng||t.default)();if(d[6]=d[6]&15|64,d[8]=d[8]&63|128,s){c=c||0;for(let u=0;u<16;++u)s[c+u]=d[u];return s}return(0,r.unsafeStringify)(d)}var o=i;return Ds.default=o,Ds}var qs={},zs={},tM;function jae(){if(tM)return zs;tM=1,Object.defineProperty(zs,"__esModule",{value:!0}),zs.default=void 0;function e(i,o,a,s){switch(i){case 0:return o&a^~o&s;case 1:return o^a^s;case 2:return o&a^o&s^a&s;case 3:return o^a^s}}function t(i,o){return i<<o|i>>>32-o}function r(i){const o=[1518500249,1859775393,2400959708,3395469782],a=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof i=="string"){const u=unescape(encodeURIComponent(i));i=[];for(let h=0;h<u.length;++h)i.push(u.charCodeAt(h))}else Array.isArray(i)||(i=Array.prototype.slice.call(i));i.push(128);const s=i.length/4+2,c=Math.ceil(s/16),d=new Array(c);for(let u=0;u<c;++u){const h=new Uint32Array(16);for(let p=0;p<16;++p)h[p]=i[u*64+p*4]<<24|i[u*64+p*4+1]<<16|i[u*64+p*4+2]<<8|i[u*64+p*4+3];d[u]=h}d[c-1][14]=(i.length-1)*8/Math.pow(2,32),d[c-1][14]=Math.floor(d[c-1][14]),d[c-1][15]=(i.length-1)*8&4294967295;for(let u=0;u<c;++u){const h=new Uint32Array(80);for(let w=0;w<16;++w)h[w]=d[u][w];for(let w=16;w<80;++w)h[w]=t(h[w-3]^h[w-8]^h[w-14]^h[w-16],1);let p=a[0],v=a[1],y=a[2],m=a[3],g=a[4];for(let w=0;w<80;++w){const x=Math.floor(w/20),_=t(p,5)+e(x,v,y,m)+g+o[x]+h[w]>>>0;g=m,m=y,y=t(v,30)>>>0,v=p,p=_}a[0]=a[0]+p>>>0,a[1]=a[1]+v>>>0,a[2]=a[2]+y>>>0,a[3]=a[3]+m>>>0,a[4]=a[4]+g>>>0}return[a[0]>>24&255,a[0]>>16&255,a[0]>>8&255,a[0]&255,a[1]>>24&255,a[1]>>16&255,a[1]>>8&255,a[1]&255,a[2]>>24&255,a[2]>>16&255,a[2]>>8&255,a[2]&255,a[3]>>24&255,a[3]>>16&255,a[3]>>8&255,a[3]&255,a[4]>>24&255,a[4]>>16&255,a[4]>>8&255,a[4]&255]}var n=r;return zs.default=n,zs}var rM;function qae(){if(rM)return qs;rM=1,Object.defineProperty(qs,"__esModule",{value:!0}),qs.default=void 0;var e=r(bz()),t=r(jae());function r(o){return o&&o.__esModule?o:{default:o}}var i=(0,e.default)("v5",80,t.default);return qs.default=i,qs}var Ls={},nM;function zae(){if(nM)return Ls;nM=1,Object.defineProperty(Ls,"__esModule",{value:!0}),Ls.default=void 0;var e="00000000-0000-0000-0000-000000000000";return Ls.default=e,Ls}var Bs={},iM;function Lae(){if(iM)return Bs;iM=1,Object.defineProperty(Bs,"__esModule",{value:!0}),Bs.default=void 0;var e=t(Jd());function t(i){return i&&i.__esModule?i:{default:i}}function r(i){if(!(0,e.default)(i))throw TypeError("Invalid UUID");return parseInt(i.slice(14,15),16)}var n=r;return Bs.default=n,Bs}var oM;function Bae(){return oM||(oM=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return a.default}});var t=u(Pae()),r=u(kae()),n=u(Dae()),i=u(qae()),o=u(zae()),a=u(Lae()),s=u(Jd()),c=u(Qd()),d=u(mz());function u(h){return h&&h.__esModule?h:{default:h}}})(k0)),k0}var A0,aM;function Fae(){if(aM)return A0;aM=1;function e(t,r){if(!t||!r||!t.length||!r.length)throw new Error("Bad alphabet");this.srcAlphabet=t,this.dstAlphabet=r}return e.prototype.convert=function(t){var r,n,i,o={},a=this.srcAlphabet.length,s=this.dstAlphabet.length,c=t.length,d=typeof t=="string"?"":[];if(!this.isValid(t))throw new Error('Number "'+t+'" contains of non-alphabetic digits ('+this.srcAlphabet+")");if(this.srcAlphabet===this.dstAlphabet)return t;for(r=0;r<c;r++)o[r]=this.srcAlphabet.indexOf(t[r]);do{for(n=0,i=0,r=0;r<c;r++)n=n*a+o[r],n>=s?(o[i++]=parseInt(n/s,10),n=n%s):i>0&&(o[i++]=0);c=i,d=this.dstAlphabet.slice(n,n+1).concat(d)}while(i!==0);return d},e.prototype.isValid=function(t){for(var r=0;r<t.length;++r)if(this.srcAlphabet.indexOf(t[r])===-1)return!1;return!0},A0=e,A0}var D0,sM;function $ae(){if(sM)return D0;sM=1;var e=Fae();function t(r,n){var i=new e(r,n);return function(o){return i.convert(o)}}return t.BIN="01",t.OCT="01234567",t.DEC="0123456789",t.HEX="0123456789abcdef",D0=t,D0}var j0,lM;function Vae(){if(lM)return j0;lM=1;const{v4:e,validate:t}=Bae(),r=$ae(),n={cookieBase90:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~",flickrBase58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",uuid25Base36:"0123456789abcdefghijklmnopqrstuvwxyz"},i={consistentLength:!0};let o;const a=(d,u,h)=>{const p=u(d.toLowerCase().replace(/-/g,""));return!h||!h.consistentLength?p:p.padStart(h.shortIdLength,h.paddingChar)},s=(d,u)=>{const p=u(d).padStart(32,"0").match(/(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})/);return[p[1],p[2],p[3],p[4],p[5]].join("-")},c=d=>Math.ceil(Math.log(2**128)/Math.log(d));return j0=(()=>{const d=(u,h)=>{const p=u||n.flickrBase58,v={...i,...h};if([...new Set(Array.from(p))].length!==p.length)throw new Error("The provided Alphabet has duplicate characters resulting in unreliable results");const y=c(p.length),m={shortIdLength:y,consistentLength:v.consistentLength,paddingChar:p[0]},g=r(r.HEX,p),w=r(p,r.HEX),x=()=>a(e(),g,m),S={alphabet:p,fromUUID:E=>a(E,g,m),maxLength:y,generate:x,new:x,toUUID:E=>s(E,w),uuid:e,validate:(E,I=!1)=>{if(!E||typeof E!="string")return!1;const N=v.consistentLength?E.length===y:E.length<=y,T=E.split("").every(M=>p.includes(M));return I===!1?N&&T:N&&T&&t(s(E,w))}};return Object.freeze(S),S};return d.constants=n,d.uuid=e,d.generate=()=>(o||(o=d(n.flickrBase58).generate),o()),d})(),j0}var yz=Vae();const xz=new vz;function Hae(e,t){switch(t.type){case"UPDATE_ROLES":return{...e,roles:t.payload,flags:{...e.flags,touched:!0}};case"UPDATE_PRIVILEGES":return{...e,privileges:t.payload,flags:{...e.flags,touched:!0}};case"SET_ROLES_CONTENT":{const{content:r,flags:n={},...i}=t.payload,o=pe.sanitizeRoles(r),a={...e.flags,...n};return{...e,...o,...i,flags:a}}case"TOGGLE_TAB":return{...e,selectedTab:t.payload};case"TOGGLE_FORCE_LOGIN":return e.forceLogin===t.payload?e:{...e,forceLogin:t.payload,flags:{...e.flags,touched:!0}};case"TOGGLE_RESTRICTED_BY_DEFAULT":return e.restrictedByDefault===t.payload?e:{...e,restrictedByDefault:t.payload,flags:{...e.flags,touched:!0}};case"SET_FLAGS":return{...e,flags:{...e.flags,...t.payload}};case"CREATE_MODAL":return{...e,modals:{...e.modals,list:[...e.modals.list,t.payload]}};case"REMOVE_MODAL":return{...e,modals:{...e.modals,list:e.modals.list.filter(r=>r.id!==t.payload)}};case"CLOSE_MODAL":{const{id:r,reason:n}=t.payload;let i;if(n)if(e.modals.list.find(a=>a.id===r))i={...e,modals:{...e.modals,list:e.modals.list.map(a=>a.id===r?{...a,closeReason:n,isOpen:!1}:a)}};else return e;else i={...e,modals:{...e.modals,list:e.modals.list.filter(o=>o.id!==r)}};return xz.next(i.modals),i}case"EDIT_MODAL":{const{id:r,...n}=t.payload;return e.modals.list.find(o=>o.id===r)?{...e,modals:{...e.modals,list:e.modals.list.map(o=>o.id===r?{...o,...n}:o)}}:e}default:return e}}const KS=C.createContext(null),Wae=()=>({roles:{},privileges:{},flags:{touched:!1},date:void 0,selectedTab:"roles",forceLogin:!1,restrictedByDefault:!1,modals:{list:[]}}),Uae=({children:e,catalog:t=null,qodly:r=!1,host:n,onSetTabFlags:i,history:o,selectedTab:a,onTabChange:s,initialState:c})=>{const[d,u]=C.useReducer(Hae,{...Wae(),...c}),h=C.useMemo(()=>t?pe.parseCatalog(t):null,[t]),p=C.useMemo(()=>({catalog:h,qodly:r,host:n,onSetTabFlags:i,history:o,selectedTab:a,onTabChange:s}),[h,r,n,i,o,a,s]);return O.jsx(KS.Provider,{value:{state:d,dispatch:u,external:p},children:e})};function Gae(){var s,c,d,u;const e=C.useContext(KS);if(!e)throw new Error("useReducerAdapter must be used within a ReducerAdapterProvider");const{state:t,dispatch:r,external:n}=e,i=C.useMemo(()=>pe.rolesToAPI({roles:t.roles,privileges:t.privileges,forceLogin:t.forceLogin,restrictedByDefault:t.restrictedByDefault}),[t.roles,t.privileges,t.forceLogin,t.restrictedByDefault]),o=C.useCallback(h=>{const{roles:p,privileges:v,forceLogin:y,restrictedByDefault:m}=pe.sanitizeRoles(h);r({type:"UPDATE_ROLES",payload:p}),r({type:"UPDATE_PRIVILEGES",payload:v}),r({type:"TOGGLE_FORCE_LOGIN",payload:y??!1}),r({type:"TOGGLE_RESTRICTED_BY_DEFAULT",payload:m??!1})},[r]),a=cz(i,o);return{getRoles:C.useCallback(()=>t.roles,[t.roles]),getPrivileges:C.useCallback(()=>t.privileges,[t.privileges]),getRolesFlags:C.useCallback(()=>t.flags,[t.flags]),getRolesAndPrivileges:C.useCallback(()=>i,[i]),getCatalog:C.useCallback(()=>n.catalog??null,[n.catalog]),getQodly:C.useCallback(()=>n.qodly??!1,[n.qodly]),getSelectedTab:C.useCallback(()=>n.selectedTab??t.selectedTab,[n.selectedTab,t.selectedTab]),getForceLogin:C.useCallback(()=>t.forceLogin??!1,[t.forceLogin]),getRestrictedByDefault:C.useCallback(()=>t.restrictedByDefault??!1,[t.restrictedByDefault]),getGuestPrivilege:C.useCallback(()=>Object.values(t.privileges).find(({privilege:h})=>h==="guest")??null,[t.privileges]),getCatalogMethods:C.useCallback(()=>{var h;return((h=n.catalog)==null?void 0:h.methods)??[]},[n.catalog]),getDataclasses:C.useCallback(()=>{var h;return((h=n.catalog)==null?void 0:h.dataClasses)??{}},[n.catalog]),getSingletons:C.useCallback(()=>{var h;return((h=n.catalog)==null?void 0:h.singletons)??{}},[n.catalog]),getHost:C.useCallback(()=>n.host??"web",[n.host]),getHistory:C.useCallback(()=>{var h,p;return{canUndo:((h=n.history)==null?void 0:h.canUndo)??a.canUndo,canRedo:((p=n.history)==null?void 0:p.canRedo)??a.canRedo}},[a.canUndo,a.canRedo,(s=n.history)==null?void 0:s.canUndo,(c=n.history)==null?void 0:c.canRedo]),actions:{updateRoles:C.useCallback(h=>{a.markEdit(),r({type:"UPDATE_ROLES",payload:h})},[a.markEdit]),updatePrivileges:C.useCallback(h=>{a.markEdit(),r({type:"UPDATE_PRIVILEGES",payload:h})},[a.markEdit]),setRolesContent:C.useCallback(h=>{r({type:"SET_ROLES_CONTENT",payload:h})},[]),toggleTab:C.useCallback(h=>{n.onTabChange&&n.onTabChange(h),n.selectedTab===void 0&&r({type:"TOGGLE_TAB",payload:h})},[n.onTabChange,n.selectedTab]),toggleForceLogin:C.useCallback(h=>{a.markEdit(),r({type:"TOGGLE_FORCE_LOGIN",payload:h})},[a.markEdit]),toggleRestrictedByDefault:C.useCallback(h=>{a.markEdit(),r({type:"TOGGLE_RESTRICTED_BY_DEFAULT",payload:h})},[a.markEdit]),setTabFlags:C.useCallback((h,p)=>{n.onSetTabFlags&&n.onSetTabFlags(h,p)},[n.onSetTabFlags]),openModal:C.useCallback(async h=>{const{type:p=pe.ModalType.ALERT}=h,v=yz.generate();return r({type:"CREATE_MODAL",payload:{id:v,type:p,isOpen:!0,...h}}),p===pe.ModalType.CONFIRM?new Promise(y=>{const m=xz.pipe(Nae(g=>{const w=g.list.find(x=>x.id===v);return w!==void 0&&!w.isOpen})).subscribe(g=>{var x;const w=g.list.find(_=>_.id===v);if(w){const _=w.closeReason===pe.ModalCloseReason.CONFIRMED,S=Xi.entries(((x=w.views)==null?void 0:x.toggles)||{}).reduce((E,I)=>({...E,[I[0]]:I[1].value}),{});r({type:"REMOVE_MODAL",payload:v}),m.unsubscribe(),y({confirmed:_,options:S})}})}):{confirmed:!1}},[r]),undo:C.useCallback(()=>{var h;if((h=n.history)!=null&&h.onUndo){n.history.onUndo();return}a.undo()},[(d=n.history)==null?void 0:d.onUndo,a.undo]),redo:C.useCallback(()=>{var h;if((h=n.history)!=null&&h.onRedo){n.history.onRedo();return}a.redo()},[(u=n.history)==null?void 0:u.onRedo,a.redo])}}}function Kae(){const e=C.useContext(KS);if(!e)throw new Error("useModals must be used within a ReducerAdapterProvider");const{state:t,dispatch:r}=e;return{modals:t.modals.list,closeModal:C.useCallback(n=>{r({type:"CLOSE_MODAL",payload:n})},[r]),editModal:C.useCallback(n=>{r({type:"EDIT_MODAL",payload:n})},[r]),removeModal:C.useCallback(n=>{r({type:"REMOVE_MODAL",payload:n})},[r])}}const q0=({child:e,parent:t,status:r})=>{const n=Tr(),i=n.getPrivileges();function o(){const s=pe.addPrivilegeIn(t.id,e.id,i);n.actions.updatePrivileges(s)}function a(){const s=pe.removePrivilegeFrom(t.id,e.id,i);n.actions.updatePrivileges(s)}return O.jsxs(vu,{color:r==="included"?"primary":"dark",onClick:r==="included"?a:o,disabled:r==="disabled",children:[e.privilege,O.jsx(ja,{className:an("transform transition-transform",{"rotate-45":r==="included"})})]})},Yae=({selectedPrivilege:e,privileges:t,onSelect:r,setShowIncluded:n,showIncluded:i})=>{const o=Object.values(t),a=pe.getPrivilegeById(e.id,t);let s=a?pe.populateShallow(a.includes,t):[],c=a?pe.populateShallow(pe.parents(a.id,t),t):[],d=a?pe.populateShallow(pe.allowed(a.id,t),t):[];return[s,c,d]=[s,c,d].map(u=>u.filter(h=>(h==null?void 0:h.privilege)!=="guest")),o.length<2&&s.length+c.length+d.length===0?null:O.jsxs(br,{depth:1,className:"w-full border-b p-4",children:[O.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[" ",o.length>2?O.jsx("h4",{className:"text-[13px] font-semibold",children:"Include a privilege"}):O.jsx("div",{}),O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx(Fu,{onChange:()=>n(!i),checked:i}),O.jsx("label",{className:"text-xs",children:" Show inherited permissions"})]})]}),O.jsxs("div",{className:"flex flex-wrap items-start justify-start gap-1",children:[s.map(u=>O.jsx(q0,{child:u,parent:e,status:"included",onSelect:r,currentPrivilegeId:u.id},u.id)),d.map(u=>O.jsx(q0,{child:u,parent:e,status:"available",onSelect:r,currentPrivilegeId:u.id},u.id)),c.map(u=>O.jsx(q0,{child:u,parent:e,status:"disabled",onSelect:r,currentPrivilegeId:u.id},u.id))]})]})};function da(e,t,r){let n=r.initialDeps??[],i,o=!0;function a(){var s,c,d;let u;r.key&&((s=r.debug)!=null&&s.call(r))&&(u=Date.now());const h=e();if(!(h.length!==n.length||h.some((y,m)=>n[m]!==y)))return i;n=h;let v;if(r.key&&((c=r.debug)!=null&&c.call(r))&&(v=Date.now()),i=t(...h),r.key&&((d=r.debug)!=null&&d.call(r))){const y=Math.round((Date.now()-u)*100)/100,m=Math.round((Date.now()-v)*100)/100,g=m/16,w=(x,_)=>{for(x=String(x);x.length<_;)x=" "+x;return x};console.info(`%c⏱ ${w(m,5)} /${w(y,5)} ms`,`
|
|
92
92
|
font-size: .6rem;
|
|
93
93
|
font-weight: bold;
|
|
94
94
|
color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,r==null?void 0:r.key)}return r!=null&&r.onChange&&!(o&&r.skipInitialOnChange)&&r.onChange(i),o=!1,i}return a.updateDeps=s=>{n=s},a}function cM(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Xae=(e,t)=>Math.abs(e-t)<1.01,Zae=(e,t,r)=>{let n;return function(...i){e.clearTimeout(n),n=e.setTimeout(()=>t.apply(this,i),r)}},uM=e=>{const{offsetWidth:t,offsetHeight:r}=e;return{width:t,height:r}},Jae=e=>e,Qae=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1),n=[];for(let i=t;i<=r;i++)n.push(i);return n},ese=(e,t)=>{const r=e.scrollElement;if(!r)return;const n=e.targetWindow;if(!n)return;const i=a=>{const{width:s,height:c}=a;t({width:Math.round(s),height:Math.round(c)})};if(i(uM(r)),!n.ResizeObserver)return()=>{};const o=new n.ResizeObserver(a=>{const s=()=>{const c=a[0];if(c!=null&&c.borderBoxSize){const d=c.borderBoxSize[0];if(d){i({width:d.inlineSize,height:d.blockSize});return}}i(uM(r))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()});return o.observe(r,{box:"border-box"}),()=>{o.unobserve(r)}},dM={passive:!0},fM=typeof window>"u"?!0:"onscrollend"in window,tse=(e,t)=>{const r=e.scrollElement;if(!r)return;const n=e.targetWindow;if(!n)return;let i=0;const o=e.options.useScrollendEvent&&fM?()=>{}:Zae(n,()=>{t(i,!1)},e.options.isScrollingResetDelay),a=u=>()=>{const{horizontal:h,isRtl:p}=e.options;i=h?r.scrollLeft*(p&&-1||1):r.scrollTop,o(),t(i,u)},s=a(!0),c=a(!1);r.addEventListener("scroll",s,dM);const d=e.options.useScrollendEvent&&fM;return d&&r.addEventListener("scrollend",c,dM),()=>{r.removeEventListener("scroll",s),d&&r.removeEventListener("scrollend",c)}},rse=(e,t,r)=>{if(t!=null&&t.borderBoxSize){const n=t.borderBoxSize[0];if(n)return Math.round(n[r.options.horizontal?"inlineSize":"blockSize"])}return e[r.options.horizontal?"offsetWidth":"offsetHeight"]},nse=(e,{adjustments:t=0,behavior:r},n)=>{var i,o;const a=e+t;(o=(i=n.scrollElement)==null?void 0:i.scrollTo)==null||o.call(i,{[n.options.horizontal?"left":"top"]:a,behavior:r})};class ise{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var r,n,i;return((i=(n=(r=this.targetWindow)==null?void 0:r.performance)==null?void 0:n.now)==null?void 0:i.call(n))??Date.now()},this.observer=(()=>{let r=null;const n=()=>r||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:r=new this.targetWindow.ResizeObserver(i=>{i.forEach(o=>{const a=()=>{const s=o.target,c=this.indexFromElement(s);if(!s.isConnected){this.observer.unobserve(s);return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(s,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var i;(i=n())==null||i.disconnect(),r=null},observe:i=>{var o;return(o=n())==null?void 0:o.observe(i,{box:"border-box"})},unobserve:i=>{var o;return(o=n())==null?void 0:o.unobserve(i)}}})(),this.range=null,this.setOptions=r=>{Object.entries(r).forEach(([n,i])=>{typeof i>"u"&&delete r[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Jae,rangeExtractor:Qae,onChange:()=>{},measureElement:rse,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...r}},this.notify=r=>{var n,i;(i=(n=this.options).onChange)==null||i.call(n,this,r)},this.maybeNotify=da(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),r=>{this.notify(r)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(r=>r()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var r;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((r=this.scrollElement)==null?void 0:r.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=o,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(r,n)=>{const i=new Map,o=new Map;for(let a=n-1;a>=0;a--){const s=r[a];if(i.has(s.lane))continue;const c=o.get(s.lane);if(c==null||s.end>c.end?o.set(s.lane,s):s.end<c.end&&i.set(s.lane,!0),i.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((a,s)=>a.end===s.end?a.index-s.index:a.end-s.end)[0]:void 0},this.getMeasurementOptions=da(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(r,n,i,o,a,s)=>(this.prevLanes!==void 0&&this.prevLanes!==s&&(this.lanesChangedFlag=!0),this.prevLanes=s,this.pendingMeasuredCacheIndexes=[],{count:r,paddingStart:n,scrollMargin:i,getItemKey:o,enabled:a,lanes:s}),{key:!1}),this.getMeasurements=da(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:r,paddingStart:n,scrollMargin:i,getItemKey:o,enabled:a,lanes:s},c)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>r)for(const p of this.laneAssignments.keys())p>=r&&this.laneAssignments.delete(p);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(p=>{this.itemSizeCache.set(p.key,p.size)}));const d=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===r&&(this.lanesSettling=!1);const u=this.measurementsCache.slice(0,d),h=new Array(s).fill(void 0);for(let p=0;p<d;p++){const v=u[p];v&&(h[v.lane]=p)}for(let p=d;p<r;p++){const v=o(p),y=this.laneAssignments.get(p);let m,g;if(y!==void 0&&this.options.lanes>1){m=y;const S=h[m],E=S!==void 0?u[S]:void 0;g=E?E.end+this.options.gap:n+i}else{const S=this.options.lanes===1?u[p-1]:this.getFurthestMeasurement(u,p);g=S?S.end+this.options.gap:n+i,m=S?S.lane:p%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(p,m)}const w=c.get(v),x=typeof w=="number"?w:this.options.estimateSize(p),_=g+x;u[p]={index:p,start:g,size:x,end:_,key:v,lane:m},h[m]=p}return this.measurementsCache=u,u},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=da(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,n,i,o)=>this.range=r.length>0&&n>0?ose({measurements:r,outerSize:n,scrollOffset:i,lanes:o}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=da(()=>{let r=null,n=null;const i=this.calculateRange();return i&&(r=i.startIndex,n=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,n]},(r,n,i,o,a)=>o===null||a===null?[]:r({startIndex:o,endIndex:a,overscan:n,count:i}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=r=>{const n=this.options.indexAttribute,i=r.getAttribute(n);return i?parseInt(i,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=r=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(i!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,i-o),s=Math.min(this.options.count-1,i+o);return r>=a&&r<=s}return!0},this.measureElement=r=>{if(!r){this.elementsCache.forEach((a,s)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(s))});return}const n=this.indexFromElement(r),i=this.options.getItemKey(n),o=this.elementsCache.get(i);o!==r&&(o&&this.observer.unobserve(o),this.observer.observe(r),this.elementsCache.set(i,r)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(r,void 0,this))},this.resizeItem=(r,n)=>{var i;const o=this.measurementsCache[r];if(!o)return;const a=this.itemSizeCache.get(o.key)??o.size,s=n-a;s!==0&&(((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,s,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",s),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,n)),this.notify(!1))},this.getVirtualItems=da(()=>[this.getVirtualIndexes(),this.getMeasurements()],(r,n)=>{const i=[];for(let o=0,a=r.length;o<a;o++){const s=r[o],c=n[s];i.push(c)}return i},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=r=>{const n=this.getMeasurements();if(n.length!==0)return cM(n[wz(0,n.length-1,i=>cM(n[i]).start,r)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const r=this.scrollElement.document.documentElement;return this.options.horizontal?r.scrollWidth-this.scrollElement.innerWidth:r.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(r,n,i=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),a=this.getScrollOffset();n==="auto"&&(n=r>=a+o?"end":"start"),n==="center"?r+=(i-o)/2:n==="end"&&(r-=o);const s=this.getMaxScrollOffset();return Math.max(Math.min(s,r),0)},this.getOffsetForIndex=(r,n="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));const i=this.getSize(),o=this.getScrollOffset(),a=this.measurementsCache[r];if(!a)return;if(n==="auto")if(a.end>=o+i-this.options.scrollPaddingEnd)n="end";else if(a.start<=o+this.options.scrollPaddingStart)n="start";else return[o,n];if(n==="end"&&r===this.options.count-1)return[this.getMaxScrollOffset(),n];const s=n==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(s,n,a.size),n]},this.scrollToOffset=(r,{align:n="start",behavior:i="auto"}={})=>{const o=this.getOffsetForAlignment(r,n),a=this.now();this.scrollState={index:null,align:n,behavior:i,startedAt:a,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(r,{align:n="auto",behavior:i="auto"}={})=>{r=Math.max(0,Math.min(r,this.options.count-1));const o=this.getOffsetForIndex(r,n);if(!o)return;const[a,s]=o,c=this.now();this.scrollState={index:r,align:s,behavior:i,startedAt:c,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(r,{behavior:n="auto"}={})=>{const i=this.getScrollOffset()+r,o=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var r;const n=this.getMeasurements();let i;if(n.length===0)i=this.options.paddingStart;else if(this.options.lanes===1)i=((r=n[n.length-1])==null?void 0:r.end)??0;else{const o=Array(this.options.lanes).fill(null);let a=n.length-1;for(;a>=0&&o.some(s=>s===null);){const s=n[a];o[s.lane]===null&&(o[s.lane]=s.end),a--}i=Math.max(...o.filter(s=>s!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(r,{adjustments:n,behavior:i})=>{this.options.scrollToFn(r,{behavior:i,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=n?n[0]:this.scrollState.lastTargetOffset,o=1,a=i!==this.scrollState.lastTargetOffset;if(!a&&Xae(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.scrollState=null;return}}else this.scrollState.stableFrames=0,a&&(this.scrollState.lastTargetOffset=i,this.scrollState.behavior="auto",this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const wz=(e,t,r,n)=>{for(;e<=t;){const i=(e+t)/2|0,o=r(i);if(o<n)e=i+1;else if(o>n)t=i-1;else return i}return e>0?e-1:0};function ose({measurements:e,outerSize:t,scrollOffset:r,lanes:n}){const i=e.length-1,o=c=>e[c].start;if(e.length<=n)return{startIndex:0,endIndex:i};let a=wz(0,i,o,r),s=a;if(n===1)for(;s<i&&e[s].end<r+t;)s++;else if(n>1){const c=Array(n).fill(0);for(;s<i&&c.some(u=>u<r+t);){const u=e[s];c[u.lane]=u.end,s++}const d=Array(n).fill(r+t);for(;a>=0&&d.some(u=>u>=r);){const u=e[a];d[u.lane]=u.start,a--}a=Math.max(0,a-a%n),s=Math.min(i,s+(n-1-s%n))}return{startIndex:a,endIndex:s}}const hM=typeof document<"u"?nt.useLayoutEffect:nt.useEffect;function ase({useFlushSync:e=!0,...t}){const r=nt.useReducer(()=>({}),{})[1],n={...t,onChange:(o,a)=>{var s;e&&a?xn.flushSync(r):r(),(s=t.onChange)==null||s.call(t,o,a)}},[i]=nt.useState(()=>new ise(n));return i.setOptions(n),hM(()=>i._didMount(),[]),hM(()=>i._willUpdate()),i}function cd(e){return ase({observeElementRect:ese,observeElementOffset:tse,scrollToFn:nse,...e})}const sse=({item:e,depth:t})=>{const r=Tr(),[n,i]=C.useState(!1),o=r.getPrivileges(),a=pe.populateShallow(e.includes,o);return O.jsxs("div",{className:"py-1 text-xs text-body",children:[O.jsxs("div",{className:"flex items-center",children:[O.jsx("button",{className:"-ml-1",onClick:s=>{s.stopPropagation(),i(!n)},children:O.jsx(uj,{className:an("h-4 w-4",{"tranform rotate-90":n})})})," ",O.jsx("div",{children:e.privilege})]}),O.jsx("div",{className:"border-l pl-2",style:{marginLeft:t?t*4:3},children:n&&O.jsx(Sz,{depth:t+1,data:a})})]})},Sz=({data:e,depth:t=0})=>e.map(r=>r.includes.length?O.jsx(sse,{item:r,depth:t},r.id):O.jsx("div",{className:an("py-1 text-xs",{}),children:r.privilege},r.id)),Br=()=>document.querySelector(`.${XD.ROLES_EDITOR_SCOPE_CLASS}`)||document.body,ef=({container:e,...t})=>O.jsx(pe.Portal,{...t,container:e||Br()}),pM=C.memo(function({privilege:t,selectedPrivilege:r,onSelect:n,isGuest:i=!1}){const o=Tr(),a=o.getPrivileges(),s=pe.populateShallow(t.includes,a),[c,d]=C.useState(!1),[u,h]=C.useState(t.privilege),[p,v]=C.useState(null),y=pe.useOutsideClick(()=>{c&&w()});pe.useDidMountEffect(()=>{t.privilege!==u&&h(t.privilege)},[t.privilege]);function m(){d(!0),v(null)}function g(){d(!1),h(t.privilege)}function w(){v(null);try{pe.validateName(u);const S=pe.renamePrivilege(u,t.id,a);o.actions.updatePrivileges(S),d(!1)}catch(S){v(S.message)}}const x=async S=>{S.stopPropagation();const{confirmed:E}=await o.actions.openModal({title:"Delete Privilege",type:pe.ModalType.CONFIRM,color:pe.ModalColor.DANGER,message:"Are you sure you want to remove this Privilege?",icon:"FdWarningDanger"});if(E){const I=pe.removePrivilege(t.id,a);if((r==null?void 0:r.id)!==t.id){o.actions.updatePrivileges(I);return}const N=Object.keys(I).filter(T=>I[T].privilege!=="guest");if(N.length===0)n(null);else{const T=Object.keys(a).filter(W=>a[W].privilege!=="guest"),M=T.indexOf(t.id),z=Math.max(0,M-1),j=T[z];M===0?n(I[N[0]]):I[j]?n(I[j]):n(I[N[0]])}o.actions.updatePrivileges(I)}},_=C.useMemo(()=>t.resources.some(S=>S.exists===!1),[t]);return O.jsx(Lr,{container:Br(),color:"negative",icon:O.jsx(wi,{}),label:"This privilege uses non-existing resources",isHidden:!_,className:"w-full",usePortal:!0,children:O.jsxs(br,{depth:4,borderType:(r==null?void 0:r.id)===t.id?"primary":_?"negative":"light",className:an("w-full rounded border p-2"),role:"button","data-cy":"privilegeCard",onClick:()=>{n(t)},ref:y,children:[O.jsxs("div",{className:"flex items-center justify-between",children:[O.jsxs("div",{className:"flex flex-1 items-center",children:[O.jsx("span",{className:"mr-4",children:i?O.jsx(wV,{className:"h-6 w-6"}):O.jsx(pd,{className:"h-6 w-6"})}),c?O.jsxs(wt.Root,{color:p?"negative":"primary",className:"flex-1 mr-2",children:[O.jsx(wt.Group,{className:"border-input-focus-border",children:O.jsx(wt.Field,{autoFocus:!0,value:u,onChange:S=>h(S.target.value),onKeyDown:S=>{S.key==="Enter"&&w(),S.key==="Escape"&&g()},type:"text"})}),p&&O.jsx(wt.Message,{children:p})]}):O.jsx("span",{className:"inline-block grow overflow-hidden truncate whitespace-nowrap text-xs font-bold",children:u})]}),i?O.jsx("div",{className:"flex items-center justify-center",children:O.jsx(Lr,{icon:O.jsx(wi,{}),label:O.jsx("div",{className:"max-w-xs flex-1 min-w-0 wrap-break-word whitespace-normal py-1",children:"Guest privileges are used to indicate resources accessible without any permission required (e.g. an authenticate function)"}),usePortal:!0,children:O.jsx(on,{className:"h-4 w-4"})})}):O.jsx("div",{className:"flex items-center gap-x-2",children:c?O.jsxs(O.Fragment,{children:[O.jsx(Jt,{variant:"ghost",color:"white",onClick:g,children:O.jsx("span",{children:O.jsx(ej,{className:"h-4 w-4"})})}),O.jsx(Jt,{variant:"ghost",color:"white",onClick:w,children:O.jsx("span",{children:O.jsx(mV,{className:"h-4 w-4"})})})]}):O.jsxs(O.Fragment,{children:[O.jsx(Jt,{variant:"ghost",color:"white",onClick:m,children:O.jsx(cj,{className:"h-4 w-4"})}),O.jsx(Jt,{variant:"ghost",color:"white",onClick:x,children:O.jsx(pj,{className:"h-4 w-4"})})]})})]}),s.length?O.jsx("div",{className:"ml-10.75",children:O.jsx(Sz,{data:s})}):null]})})}),lse=({privileges:e,selectPrivilege:t,selectedPrivilege:r})=>{const n=Tr(),i=n.getGuestPrivilege(),o=n.getCatalog(),a=C.useMemo(()=>{if(o===null||!i)return i;const u=sz({guest:i},Object.values((o==null?void 0:o.dataClasses)??{}));return lz(u,o).guest},[e,o]),s=C.useMemo(()=>Object.entries(e).filter(([,u])=>u.privilege!=="guest").sort(([,u],[,h])=>pe.localeCompare(u.privilege,h.privilege)),[e]),c=C.useRef(null),d=cd({count:s.length,getScrollElement:()=>c.current,estimateSize:()=>72,overscan:5});return O.jsxs("div",{ref:c,className:"flex flex-1 flex-col overflow-auto p-4 pb-10 pt-1",children:[a?O.jsx("div",{className:"mb-4",children:O.jsx(pM,{privilege:a,onSelect:t,selectedPrivilege:r,privileges:e,isGuest:!0})}):null,s.length?O.jsx("div",{style:{position:"relative",height:`${d.getTotalSize()}px`},children:d.getVirtualItems().map(u=>{const[h,p]=s[u.index];return O.jsx("div",{ref:d.measureElement,"data-index":u.index,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${u.start}px)`,paddingBottom:"16px"},children:O.jsx(pM,{privilege:p,onSelect:t,selectedPrivilege:r,privileges:e})},h)})}):O.jsx("div",{className:"flex h-full items-center justify-center",children:O.jsx("div",{className:"flex flex-1 items-center justify-center",children:O.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-4 text-inactive-text",children:[O.jsx(on,{className:"h-10 w-10"}),O.jsx("div",{className:"font-semibold",children:"There are no privileges"}),O.jsxs("div",{className:"flex items-center text-sm",children:["Create a new Privilege by clicking on the"," ",O.jsx(ja,{className:"ml-2 inline h-4 w-4"})]})]})})})]})};var au={exports:{}},su={exports:{}},ft={};/** @license React v16.13.1
|
|
@@ -116,5 +116,5 @@ Valid keys: `+JSON.stringify(Object.keys(P),null," "));var Z=ve(q,ne,D,$,H+"."+
|
|
|
116
116
|
`)&&(B="(?: "+B+")",Q=" "+Q,X++),W=new RegExp("^(?:"+B+")",P)),_&&(W=new RegExp("^"+B+"$(?!\\s)",P)),w&&(U=N.lastIndex),A=e(h,re?W:N,Q),re?A?(A.input=g(A.input,X),A[0]=g(A[0],X),A.index=N.lastIndex,N.lastIndex+=A[0].length):N.lastIndex=0:w&&A&&(N.lastIndex=N.global?A.index+A[0].length:U),_&&A&&A.length>1&&e(u,A[0],W,function(){for(K=1;K<arguments.length-2;K++)arguments[K]===void 0&&(A[K]=void 0)}),A&&G)for(A.groups=V=a(null),K=0;K<G.length;K++)te=G[K],V[te[0]]=A[te[1]];return A}),pw=p,pw}var OD;function uL(){if(OD)return yD;OD=1;var e=no(),t=fE();return e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t}),yD}uL();var CD={},vw,ID;function dL(){if(ID)return vw;ID=1,uL();var e=Ur(),t=zo(),r=fE(),n=St(),i=Pr(),o=Bl(),a=i("species"),s=RegExp.prototype;return vw=function(c,d,u,h){var p=i(c),v=!n(function(){var w={};return w[p]=function(){return 7},""[c](w)!==7}),y=v&&!n(function(){var w=!1,x=/a/;return c==="split"&&(x={},x.constructor={},x.constructor[a]=function(){return x},x.flags="",x[p]=/./[p]),x.exec=function(){return w=!0,null},x[p](""),!w});if(!v||!y||u){var m=/./[p],g=d(p,""[c],function(w,x,_,S,E){var I=x.exec;return I===r||I===s.exec?v&&!E?{done:!0,value:e(m,x,_,S)}:{done:!0,value:e(w,_,x,S)}:{done:!1}});t(String.prototype,c,g[0]),t(s,p,g[1])}h&&o(s[p],"sham",!0)},vw}var gw,RD;function fL(){if(RD)return gw;RD=1;var e=Xz().charAt;return gw=function(t,r,n){return r+(n?e(t,r).length:1)},gw}var mw,ND;function Gle(){if(ND)return mw;ND=1;var e=Gt(),t=St(),r=e.RegExp,n=!t(function(){var i=!0;try{r(".","d")}catch{i=!1}var o={},a="",s=i?"dgimsy":"gimsy",c=function(p,v){Object.defineProperty(o,p,{get:function(){return a+=v,!0}})},d={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};i&&(d.hasIndices="d");for(var u in d)c(u,d[u]);var h=Object.getOwnPropertyDescriptor(r.prototype,"flags").get.call(o);return h!==s||a!==s});return mw={correct:n},mw}var bw,TD;function hL(){if(TD)return bw;TD=1;var e=Ur(),t=In(),r=of(),n=Gle(),i=cL(),o=RegExp.prototype;return bw=n.correct?function(a){return a.flags}:function(a){return!n.correct&&r(o,a)&&!t(a,"flags")?e(i,a):a.flags},bw}var yw,PD;function pL(){if(PD)return yw;PD=1;var e=Ur(),t=Rn(),r=er(),n=ro(),i=fE(),o=TypeError;return yw=function(a,s){var c=a.exec;if(r(c)){var d=e(c,a,s);return d!==null&&t(d),d}if(n(a)==="RegExp")return e(i,a,s);throw new o("RegExp#exec called on incompatible receiver")},yw}var MD;function Kle(){if(MD)return CD;MD=1;var e=Ur(),t=yt(),r=dL(),n=Rn(),i=dr(),o=aE(),a=Lo(),s=qo(),c=Ll(),d=fL(),u=hL(),h=pL(),p=t("".indexOf);return r("match",function(v,y,m){return[function(w){var x=s(this),_=i(w)?c(w,v):void 0;return _?e(_,w,x):new RegExp(w)[v](a(x))},function(g){var w=n(this),x=a(g),_=m(y,w,x);if(_.done)return _.value;var S=a(u(w));if(p(S,"g")===-1)return h(w,x);var E=p(S,"u")!==-1;w.lastIndex=0;for(var I=[],N=0,T;(T=h(w,x))!==null;){var M=a(T[0]);I[N]=M,M===""&&(w.lastIndex=d(x,o(w.lastIndex),E)),N++}return N===0?null:I}]}),CD}Kle();var kD={},xw,AD;function Yle(){if(AD)return xw;AD=1;var e=jz(),t=Ii();return xw=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)},xw}var DD;function Xle(){if(DD)return kD;DD=1;var e=Wn(),t=iE().EXISTS,r=yt(),n=Yle(),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""}}}),kD}Xle();var jD={},ww,qD;function Zle(){if(qD)return ww;qD=1;var e=tf(),t=Function.prototype,r=t.apply,n=t.call;return ww=typeof Reflect=="object"&&Reflect.apply||(e?n.bind(r):function(){return n.apply(r,arguments)}),ww}var Sw,zD;function Jle(){if(zD)return Sw;zD=1;var e=yt(),t=Ya(),r=Math.floor,n=e("".charAt),i=e("".replace),o=e("".slice),a=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,s=/\$([$&'`]|\d{1,2})/g;return Sw=function(c,d,u,h,p,v){var y=u+c.length,m=h.length,g=s;return p!==void 0&&(p=t(p),g=a),i(v,g,function(w,x){var _;switch(n(x,0)){case"$":return"$";case"&":return c;case"`":return o(d,0,u);case"'":return o(d,y);case"<":_=p[o(x,1,-1)];break;default:var S=+x;if(S===0)return w;if(S>m){var E=r(S/10);return E===0?w:E<=m?h[E-1]===void 0?n(x,1):h[E-1]+n(x,1):w}_=h[S-1]}return _===void 0?"":_})},Sw}var LD;function Qle(){if(LD)return jD;LD=1;var e=Zle(),t=Ur(),r=yt(),n=dL(),i=St(),o=Rn(),a=er(),s=dr(),c=lf(),d=aE(),u=Lo(),h=qo(),p=fL(),v=Ll(),y=Jle(),m=hL(),g=pL(),w=Pr(),x=w("replace"),_=Math.max,S=Math.min,E=r([].concat),I=r([].push),N=r("".indexOf),T=r("".slice),M=function(U){return U===void 0?U:String(U)},z=(function(){return"a".replace(/./,"$0")==="$0"})(),j=(function(){return/./[x]?/./[x]("a","$0")==="":!1})(),W=!i(function(){var U=/./;return U.exec=function(){var A=[];return A.groups={a:"7"},A},"".replace(U,"$<a>")!=="7"});return n("replace",function(U,A,K){var V=j?"$":"$0";return[function(G,re){var P=h(this),B=s(G)?v(G,x):void 0;return B?t(B,G,P,re):t(A,u(P),G,re)},function(te,G){var re=o(this),P=u(te);if(typeof G=="string"&&N(G,V)===-1&&N(G,"$<")===-1){var B=K(A,re,P,G);if(B.done)return B.value}var X=a(G);X||(G=u(G));var Q=u(m(re)),D=N(Q,"g")!==-1,$;D&&($=N(Q,"u")!==-1,re.lastIndex=0);for(var H=[],q;q=g(re,P),!(q===null||(I(H,q),!D));){var Y=u(q[0]);Y===""&&(re.lastIndex=p(P,d(re.lastIndex),$))}for(var ie="",ne=0,ve=0;ve<H.length;ve++){q=H[ve];for(var Z=u(q[0]),J=_(S(c(q.index),P.length),0),ae=[],he,ue=1;ue<q.length;ue++)I(ae,M(q[ue]));var de=q.groups;if(X){var le=E([Z],ae,J,P);de!==void 0&&I(le,de),he=u(e(G,void 0,le))}else he=y(Z,P,J,ae,de,G);J>=ne&&(ie+=T(P,ne,J)+he,ne=J+Z.length)}return ie+T(P,ne)}]},!W||!z||j),jD}Qle();function Wi(e){return!e||!e.ownerDocument||!e.ownerDocument.defaultView?window:e.ownerDocument.defaultView}function Nu(e){return!e||!e.ownerDocument?document:e.ownerDocument}var ma=null,BD=null;lL&&window.addEventListener("resize",function(){BD!==window.devicePixelRatio&&(BD=window.devicePixelRatio,ma=null)});function FD(e){if(ma===null){var t=Nu(e);if(typeof t>"u")return ma=0,ma;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),ma=i}return ma}var ud=(function(){function e(r,n){var i=this;this.onScroll=function(){var o=Wi(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],d=i.axis[i.draggedAxis].scrollbar,u=i.contentWrapperEl[i.axis[i.draggedAxis].scrollSizeAttr],h=parseInt(i.elStyles[i.axis[i.draggedAxis].sizeAttr],10);o.preventDefault(),o.stopPropagation(),i.draggedAxis==="y"?a=o.pageY:a=o.pageX;var p=a-s.rect[i.axis[i.draggedAxis].offsetAttr]-i.axis[i.draggedAxis].dragOffset,v=p/(c-d.size),y=v*(u-h);i.draggedAxis==="x"&&(y=i.isRtl&&e.getRtlHelpers().isRtlScrollbarInverted?y-(c+d.size):y,y=i.isRtl&&e.getRtlHelpers().isRtlScrollingInverted?-y:y),i.contentWrapperEl[i.axis[i.draggedAxis].scrollOffsetAttr]=y},this.onEndDrag=function(o){var a=Nu(i.el),s=Wi(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=QA(this.recalculate.bind(this),64),this.onMouseMove=QA(this.onMouseMove.bind(this),64),this.hideScrollbars=tD(this.hideScrollbars.bind(this),this.options.timeout),this.onWindowResize=tD(this.onWindowResize.bind(this),64,{leading:!0}),e.getRtlHelpers=vle(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=Nu(n),a=Wi(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),lL&&(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=Wi(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||jle;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=Wi(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,d=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 u=this.contentEl.scrollHeight,h=this.contentEl.scrollWidth;this.contentWrapperEl.style.height=i?"auto":"100%",this.placeholderEl.style.width=o?a+"px":"auto",this.placeholderEl.style.height=u+"px";var p=this.contentWrapperEl.offsetHeight;this.axis.x.isOverflowing=h>a,this.axis.y.isOverflowing=u>p,this.axis.x.isOverflowing=c==="hidden"?!1:this.axis.x.isOverflowing,this.axis.y.isOverflowing=d==="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 v=this.axis.x.isOverflowing?this.scrollbarWidth:0,y=this.axis.y.isOverflowing?this.scrollbarWidth:0;this.axis.x.isOverflowing=this.axis.x.isOverflowing&&h>s-y,this.axis.y.isOverflowing=this.axis.y.isOverflowing&&u>p-v,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 d=c/(i-a),u=~~((o-s.size)*d);u=n==="x"&&this.isRtl&&e.getRtlHelpers().isRtlScrollbarInverted?u+(o-s.size):u,s.el.style.transform=n==="x"?"translate3d("+u+"px, 0, 0)":"translate3d(0, "+u+"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=Nu(this.el),a=Wi(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=Wi(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],d=parseInt(this.elStyles[this.axis[i].sizeAttr],10),u=this.contentWrapperEl[this.axis[i].scrollOffsetAttr],h=i==="y"?this.mouseY-c:this.mouseX-c,p=h<0?-1:1,v=p===-1?u-d:u+d,y=function m(){if(p===-1){if(u>v){var g;u-=o.options.clickOnTrackSpeed,o.contentWrapperEl.scrollTo((g={},g[o.axis[i].offsetAttr]=u,g)),a.requestAnimationFrame(m)}}else if(u<v){var w;u+=o.options.clickOnTrackSpeed,o.contentWrapperEl.scrollTo((w={},w[o.axis[i].offsetAttr]=u,w)),a.requestAnimationFrame(m)}};y()}},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:FD(this.el)}catch{return FD(this.el)}},t.removeListeners=function(){var n=this,i=Wi(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})();ud.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};ud.instances=new WeakMap;function $D(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 du(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?$D(Object(r),!0).forEach(function(n){ece(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$D(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ece(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function dd(){return dd=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},dd.apply(this,arguments)}function tce(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 rce(e,t){if(e==null)return{};var r=tce(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 nce=["children","scrollableNodeProps","tag"],ice=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},hf=C.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=rce(e,nce),c=a,d,u=C.useRef(),h=C.useRef(),p=C.useRef(),v={},y={},m=[];return Object.keys(s).forEach(function(g){Object.prototype.hasOwnProperty.call(ud.defaultOptions,g)?v[g]=s[g]:g.match(/data-simplebar-(.+)/)&&g!=="data-simplebar-direction"?m.push({name:g,value:s[g]}):y[g]=s[g]}),m.length&&console.warn(`simplebar-react: this way of passing options is deprecated. Pass it like normal props instead:
|
|
117
117
|
'data-simplebar-auto-hide="false"' —> 'autoHide="false"'
|
|
118
118
|
`),C.useEffect(function(){return u=i.ref||u,h.current&&(d=new ud(h.current,du(du(du(du({},ice(m)),v),u&&{scrollableNode:u.current}),p.current&&{contentNode:p.current})),typeof t=="function"?t(d):t&&(t.current=d)),function(){d.unMount(),d=null,typeof t=="function"&&t(null)}},[]),C.createElement(c,dd({ref:h,"data-simplebar":!0},y),C.createElement("div",{className:"simplebar-wrapper"},C.createElement("div",{className:"simplebar-height-auto-observer-wrapper"},C.createElement("div",{className:"simplebar-height-auto-observer"})),C.createElement("div",{className:"simplebar-mask"},C.createElement("div",{className:"simplebar-offset"},typeof r=="function"?r({scrollableNodeRef:u,contentNodeRef:p}):C.createElement("div",dd({},i,{className:"simplebar-content-wrapper".concat(i.className?" ".concat(i.className):"")}),C.createElement("div",{className:"simplebar-content"},r)))),C.createElement("div",{className:"simplebar-placeholder"})),C.createElement("div",{className:"simplebar-track simplebar-horizontal"},C.createElement("div",{className:"simplebar-scrollbar"})),C.createElement("div",{className:"simplebar-track simplebar-vertical"},C.createElement("div",{className:"simplebar-scrollbar"})))});hf.displayName="SimpleBar";hf.propTypes={children:Fs.oneOfType([Fs.node,Fs.func]),scrollableNodeProps:Fs.object,tag:Fs.string};const vL=e=>{switch(e){case pe.EPermissionType.DATACLASS:return O.jsx(Pu,{className:"h-6 w-6"});case pe.EPermissionType.SINGLETON:return O.jsx(fj,{className:"h-6 w-6"});case pe.EPermissionType.DATASTORE:return O.jsx(lj,{className:"h-6 w-6"});case pe.EPermissionType.ATTRIBUTE:return O.jsx(hj,{className:"h-6 w-6"});case pe.EPermissionType.METHOD:return O.jsx(tj,{className:"h-6 w-6"});case pe.EPermissionType.SINGLETON_METHOD:return O.jsx(sj,{className:"h-6 w-6"});case pe.ESubPermissionType.ENTITY_SEL_METHOD:return O.jsx(aj,{className:"h-6 w-6"});case pe.ESubPermissionType.ENTITY_METHOD:return O.jsx(oj,{className:"h-6 w-6"});case pe.ESubPermissionType.DS_METHOD:return O.jsx(ij,{className:"h-6 w-6"});case pe.ESubPermissionType.DATACLASS_METHOD:return O.jsx(nj,{className:"h-6 w-6"});default:return O.jsx(Pu,{className:"h-6 w-6"})}},VD=({children:e})=>O.jsx("div",{className:"h-full w-full",children:O.jsx("div",{className:"flex h-full w-full flex-1 items-center justify-center",children:O.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-4 py-4 text-inactive-text",children:[O.jsx(on,{className:"h-10 w-10"}),O.jsx("div",{className:"text-center text-sm",children:e})]})})}),fa=({permissions:e,label:t,onToggle:r,onSelect:n,promoted:i,privileges:o,exists:a,optimisticChecked:s})=>{const c=e.find(u=>u.name===t);if(!c)return null;const d=s!==void 0?s:c.checked;return O.jsxs("div",{className:"relative mx-auto flex w-fit items-center",children:[O.jsx(ir,{value:d||c.from.length===0||t==="promote"?d:null,onChange:()=>r&&r(c),isInvalid:a===!1}),O.jsxs("div",{className:"absolute left-full translate-x-1/4 inset-y-0 flex cursor-pointer items-center gap-x-1",children:[t!=="promote"&&(c.checked&&(c.info||c.from.length>0)||!c.checked&&c.from.length>0)&&O.jsx(O.Fragment,{children:O.jsx(Lr,{container:Br(),delay:100,label:O.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?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:c.from.map(u=>{var h;return O.jsx("li",{className:"cursor-pointer list-disc font-bold hover:underline",onClick:()=>{var p;return n((p=o[u])==null?void 0:p.id)},children:(h=o[u])==null?void 0:h.privilege})})})]})]}):null,c.info&&O.jsxs("div",{className:"flex items-start",children:[O.jsx(Ew,{className:"mr-2 mt-0.5 h-4 w-4 shrink-0"})," ",O.jsx("span",{className:"flex-1 min-w-0 wrap-break-word whitespace-normal text-left",children:c.info})]})]}),children:O.jsx(on,{className:"h-4 w-4 "})})}),(c.checked||c.from.length>0)&&["execute"].includes(t)&&!!(i!=null&&i.length)&&O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:O.jsxs("div",{className:"flex items-start text-s",children:[O.jsx(Ew,{className:"mr-2 mt-0.5 h-4 w-4 shrink-0"}),O.jsxs("p",{children:[O.jsx("span",{className:"mr-1",children:"Function is promoted with: "}),i==null?void 0:i.map(u=>{var h;return O.jsx("li",{className:"cursor-pointer list-disc font-bold hover:underline",onClick:()=>{var p;return n((p=o[u])==null?void 0:p.id)},children:(h=o[u])==null?void 0:h.privilege})})]})]})}),children:O.jsx(xV,{className:"h-3 w-3 "})})]})]})},oce=({privilegeId:e,privileges:t})=>{const r=Tr(),n=r.getCatalogMethods(),i=r.getDataclasses(),o=r.getSingletons(),[a,s]=C.useState([]),[c,d]=C.useState("");C.useEffect(()=>{d("")},[e]),C.useEffect(()=>{const p=pe.getInheritedResources(e,t).map(({resource:y,type:m,subType:g})=>({applyTo:y,type:m,subType:g})),v=US(c.toLowerCase(),n,Object.values(i),Object.values(o));s(v.filter(({applyTo:y,type:m,subType:g})=>!Xi.find(p,{applyTo:y,type:m,subType:g})))},[c,e,t,n,i,o]);const[u,h]=C.useState(!1);return O.jsx(Kh.Root,{className:"w-56",onInputChange:p=>d(p||""),onOpenChange:h,isOpen:u,isSearchable:!0,options:a,getOptionLabel:p=>p?p.applyTo:"",getOptionValue:p=>p?p.applyTo:"",value:null,clearSearchOnSelect:!0,closeMenuOnSelect:!1,onChange:p=>{if(!p)return;const v=pe.addPermission(e,p,t);r.actions.updatePrivileges(v),d("")},children:O.jsx(Kh.Group,{children:O.jsx(Kh.Field,{controlShouldRenderValue:!0,renderOption:({data:p})=>O.jsxs("div",{className:"flex items-center gap-x-2",children:[vL(p.type),O.jsx("span",{children:p.applyTo})]}),placeholder:"Create a permission",hideNoOptions:!0})})})};function ace(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 bo={datastore:["datastore"],dataclass:["dataclass"],singleton:["singleton"],functions:["method","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"],attribute:["attribute"]},HD=Object.values(bo).flat();function ha(e,t){return t.length>0&&t.every(r=>e.includes(r))}function sce(e,t){return t.some(r=>e.includes(r))}function lce(e,t){return Array.from(new Set([...e,...t]))}function cce(e,t){return e.filter(r=>!t.includes(r))}const uce=({selectedPrivilege:e,onSelect:t,showIncluded:r,privileges:n,rawPrivileges:i})=>{var ne,ve;const[o,a]=C.useState(null),[s,c]=C.useState(null),{styles:d,attributes:u}=Cd(o,s,{modifiers:[{name:"offset",options:{offset:[0,10]}}]}),h=Tr(),[p,v]=C.useState([]),[y,m]=C.useState([]),[g,w]=C.useState(""),[x,_]=C.useState(""),[S,E]=C.useState({}),I=i??n;C.useEffect(()=>{const Z=setTimeout(()=>m(p),0);return()=>clearTimeout(Z)},[p]),C.useEffect(()=>{E({})},[I]);const{id:N}=e,T=C.useMemo(()=>pe.getInheritedResources(N,I),[N,(ne=I[N])==null?void 0:ne.includes,(ve=I[N])==null?void 0:ve.resources]),M=C.useMemo(()=>pe.getPromotions(N,I),[I[N]]),z=Z=>{v([...Z])},j=Z=>{v(J=>ha(J,Z)?cce(J,Z):lce(J,Z))},W=Z=>{j(bo[Z])},U=ha(p,HD),A=p.length>0&&!U,K=ha(p,bo.functions),V=!K&&sce(p,bo.functions),te=()=>z(HD),G=()=>z([]),re=async Z=>{if(h.getHost()==="vscode"){const ae=pe.removePermission(e.id,Z,n);h.actions.updatePrivileges(ae);return}const{confirmed:J}=await h.actions.openModal({title:"Delete Privilege",type:pe.ModalType.CONFIRM,color:pe.ModalColor.DANGER,message:"Are you sure you want to remove this Privilege?",icon:"FdWarningDanger"});if(J){const ae=pe.removePermission(e.id,Z,n);h.actions.updatePrivileges(ae)}},P=async()=>{const{confirmed:Z}=await h.actions.openModal({title:"Reset Permissions",type:pe.ModalType.CONFIRM,color:pe.ModalColor.DANGER,message:"Are you sure you want to reset permissions for this Privilege?",icon:"FdWarningDanger"});if(Z){const J=pe.resetResources(e.id,n);h.actions.updatePrivileges(J)}},B=C.useMemo(()=>y.length>0?T.filter(Z=>y.includes(Z.type)):T,[T,y]),X=C.useMemo(()=>B.filter(({resource:Z})=>x?new RegExp(Xi.escapeRegExp(x),"i").test(Z):!0),[B,x]),Q=C.useMemo(()=>ace(X),[X]),D=C.useMemo(()=>Q.filter(Z=>{const J=Z.permissions.every(ae=>!ae.checked)&&Z.permissions.some(ae=>ae.from.length>0);return r||!J}),[Q,r]),$=(Z,J)=>{const ae=`${Z.resource}|${Z.type}|${J.name}`;E(he=>({...he,[ae]:!J.checked})),setTimeout(()=>{const he=pe.togglePermission(e.id,Z,J,n);h.actions.updatePrivileges(he)},0)},H=C.useMemo(()=>D.some(Z=>Z.exists===!1),[D]),q=async()=>{const{confirmed:Z}=await h.actions.openModal({title:"Delete Privilege",type:pe.ModalType.CONFIRM,color:pe.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"}),J=Object.entries(I).map(([ae,he])=>{const ue=he.resources.filter(de=>!de.exists);return{[ae]:ue.map(de=>({applyTo:de.resource,type:de.type}))}}).reduce((ae,he)=>({...ae,...he}),{});if(Z){const ae=pe.removeMultiplePermissions(J,n);h.actions.updatePrivileges(ae)}},Y=C.useRef(null),ie=cd({count:D.length,getScrollElement:()=>{var Z;return((Z=Y.current)==null?void 0:Z.getScrollElement())??null},estimateSize:()=>36,overscan:5});return C.useEffect(()=>{var Z,J;(J=(Z=Y.current)==null?void 0:Z.getScrollElement())==null||J.scrollTo({top:0})},[N]),O.jsxs(hf,{ref:Y,className:"z-20 h-full flex-1 overflow-auto p-3.75 pt-0",style:{maxHeight:"calc(100vh - 5.5rem - 85px - 20px)"},children:[O.jsxs("table",{className:"relative h-full w-full border-collapse",children:[O.jsx("thead",{className:"sticky top-0 z-20 bg-panel-1",children:O.jsxs("tr",{className:"border-b border-panel-border-subtle",children:[O.jsx("td",{className:"py-2",children:O.jsxs("div",{className:"flex items-center gap-x-2",children:[O.jsx(wt.Root,{className:"relative w-56",children:O.jsxs(wt.Group,{children:[O.jsx(wt.Icon,{children:O.jsx(dj,{})}),O.jsx(wt.Field,{type:"text",placeholder:"Search available permissions",value:g,onChange:Z=>{const J=Z.target.value;w(J),setTimeout(()=>_(J),0)}}),O.jsx(wn.Popover,{className:"flex items-center",children:({open:Z})=>O.jsxs(O.Fragment,{children:[O.jsx(wn.Popover.Button,{ref:a,children:O.jsx(wt.Icon,{isAction:!0,children:O.jsx(JD,{})})}),Z&&O.jsx(ef,{children:O.jsx(wn.Popover.Panel,{ref:c,style:d.popper,...u.popper,className:"z-50",static:!0,children:O.jsxs(br,{depth:3,borderType:"light",className:"rounded-md border px-4 py-2.5",children:[O.jsxs("label",{className:"mb-2 flex cursor-pointer items-center gap-2",children:[O.jsx(ir,{size:"sm",value:A?null:U,onChange:()=>U?G():te()}),O.jsx("h5",{className:"text-sm font-semibold",children:"Filter"})]}),O.jsxs("div",{className:"space-y-2 text-s",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:ha(p,bo.dataclass),onChange:()=>W("dataclass"),label:"Dataclass"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:ha(p,bo.singleton),onChange:()=>W("singleton"),label:"Singleton"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:V?null:K,onChange:()=>W("functions"),label:"Functions"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:ha(p,bo.attribute),onChange:()=>W("attribute"),label:"Attribute"})})]})]})})})]})})]})}),O.jsx(oce,{privilegeId:N,privileges:I}),O.jsx("div",{children:O.jsx(Lr,{label:`Resetting the privilege will remove all configured\r
|
|
119
|
-
ressources`,container:Br(),children:O.jsx(Jt,{color:"white",variant:"ghost",onClick:P,children:O.jsx(SV,{})})})}),O.jsx(Lr,{icon:O.jsx(wi,{}),label:"Delete all the non existing resources from privileges",container:Br(),children:O.jsx(Jt,{color:"white",variant:"ghost",onClick:q,disabled:!H,children:O.jsx(QD,{className:"h-4 w-4"})})})]})}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Read"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Create"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Update"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Delete"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Execute"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Promote"})]})}),D.length?O.jsxs("tbody",{children:[ie.getVirtualItems().length>0?O.jsx("tr",{style:{height:`${ie.getVirtualItems()[0].start}px`},children:O.jsx("td",{colSpan:7})}):null,ie.getVirtualItems().map(Z=>{const J=D[Z.index],ae=J.permissions.some(he=>he.from.length>0);return O.jsxs("tr",{className:an("group even:bg-white/5 hover:bg-input-bg",{"opacity-60":J.exists===!1}),children:[O.jsxs("td",{className:an("group flex items-center gap-3 py-2 text-xs group-hover:rounded-l group-hover:bg-input-bg ",J.exists===!1?"text-negative-text":""),children:[vL(J.type),J.resource,O.jsx(Lr,{label:"Remove Permission",container:Br(),children:O.jsx(Jt,{color:"white",variant:"ghost",disabled:ae,onClick:()=>{ae?pe.toastSubject.next({kind:"info",markdown:!0,message:"**Info:** Inherited permissions can't be removed",customIcon:on}):re({applyTo:J.resource,type:J.type})},className:"opacity-0 group-hover:opacity-100",children:O.jsx(ja,{className:"h-4 w-4 rotate-45 transform"})})})]}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"read",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|read`]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"create",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|create`]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"update",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|update`]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"drop",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|drop`]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:O.jsx(fa,{promoted:M[J.resource],permissions:J.permissions,showIncluded:r,label:"execute",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|execute`]})}),O.jsx("td",{className:"py-2 text-center group-hover:rounded-r group-hover:bg-input-bg",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"promote",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|promote`]})})]},`${J.resource}-${Z.index}`)}),(()=>{const Z=ie.getVirtualItems();if(!Z.length)return null;const J=ie.getTotalSize()-Z[Z.length-1].end;return J>0?O.jsx("tr",{style:{height:`${J}px`},children:O.jsx("td",{colSpan:7})}):null})()]}):null]}),!Q.length&&x?O.jsx(VD,{children:"The Permission you're looking for can't be found "}):null,!Q.length&&!x?O.jsxs(VD,{children:["This Privilege has no Permissions configured yet ",O.jsx("br",{}),'Add a new permission by using the "Create a permission" input above']}):null]})},dce=({onCreate:e})=>{const t=Tr(),r=t.getPrivileges(),[n,i]=C.useState(null),[o,a]=C.useState(null),[s,c]=C.useState(""),[d,u]=C.useState(null),{styles:h,attributes:p}=Cd(n,o,{modifiers:[{name:"offset",options:{offset:[-10,10]}}],placement:"right-start"});C.useEffect(()=>{c(""),u(null)},[o]);const v=(y=()=>{})=>{u(null);try{const m=pe.createPrivilege(s,r),g=Object.values(m).find(w=>w.privilege===s);t.actions.updatePrivileges(m),g&&e(g),setTimeout(()=>{y()},0)}catch(m){u(m.message)}};return O.jsx(wn.Popover,{children:({open:y,close:m})=>O.jsxs(O.Fragment,{children:[O.jsx(wn.Popover.Button,{className:"rounded","data-cy":"New-priv-btn",as:"div",ref:i,children:O.jsx(Jt,{variant:"ghost",color:"white",children:O.jsx(ja,{className:"h-4 w-4"})})}),y&&O.jsx(ef,{children:O.jsx(wn.Popover.Panel,{ref:a,style:h.popper,...p.popper,"data-cy":"New-priv-pop-up",className:"z-50",static:!0,children:O.jsxs(br,{className:"min-w-[256px] border rounded px-4 py-2 text-xs shadow-md",depth:3,borderType:"light",children:[O.jsx("h5",{className:"mb-2 text-xs font-semibold",children:"Create New Privilege"}),O.jsx("div",{className:"mt-2",children:O.jsxs("label",{className:"flex items-center gap-x-4",children:[O.jsx("span",{children:"Name"}),O.jsx(wt.Root,{className:"w-full",color:d?"negative":"primary",children:O.jsxs(wt.Group,{children:[d&&O.jsx(wt.Message,{children:d}),O.jsx(wt.Field,{autoFocus:!0,value:s,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Enter"&&v()},type:"text"})]})})]})}),O.jsxs("div",{className:"mt-4 flex items-center justify-center gap-x-2",children:[O.jsx(Jt,{onClick:()=>v(m),children:"Create"}),O.jsx(Jt,{color:"white",variant:"outline",onClick:()=>m(),children:"Cancel"})]})]})})})]})})},fce=()=>{const e=Tr(),t=e.getCatalog(),r=e.getPrivileges(),[n,i]=C.useState(r);C.useEffect(()=>{const y=setTimeout(()=>i(r),0);return()=>clearTimeout(y)},[r]);const o=C.useMemo(()=>{if(t===null)return n;const y=sz(n,Object.values((t==null?void 0:t.dataClasses)??{}));return lz(y,t)},[n,t]),[a,s]=C.useState(null),[c,d]=C.useState(null),u=y=>{s(y),setTimeout(()=>d(y),0)},h=C.useMemo(()=>Object.keys(o),[o]);C.useEffect(()=>{if(a&&o[a.id]||!h.length)return;const y=o[h[0]];s(y),d(y)},[o]),C.useEffect(()=>{h.length<2&&v(!0)},[h.length]);const[p,v]=C.useState(!0);return O.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-1",children:[O.jsxs(br,{depth:1,className:"flex h-full w-89 shrink-0 flex-col border-r",children:[O.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between px-3.5 py-2.5",children:[O.jsxs("div",{className:"flex items-center gap-x-1",children:[O.jsx("span",{children:O.jsx(pd,{className:"h-3.5 w-3.5"})}),O.jsx("span",{className:"text-[11px] font-semibold",children:"Privileges"})]}),O.jsx(dce,{onCreate:y=>{s(y),d(y)}})]}),O.jsx(lse,{privileges:o,selectedPrivilege:a,selectPrivilege:u})]}),a&&o[a.id]?O.jsxs(br,{depth:1,className:"privileges-container relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden border-l-[0.5px]",children:[O.jsxs("div",{className:"mb-1 flex min-h-0 min-w-0 flex-1 h-full w-full flex-col items-stretch overflow-auto",children:[(c??a).privilege!=="guest"?O.jsx(Yae,{privileges:o,selectedPrivilege:c??a,onSelect:y=>s(r[y]),setShowIncluded:v,showIncluded:p}):null,O.jsx(uce,{privileges:o,rawPrivileges:r,selectedPrivilege:c??a,onSelect:y=>s(r[y]),showIncluded:p})]}),O.jsx("div",{className:"mt-auto flex-shrink-0",children:O.jsx(hce,{privileges:o,selectedPrivilege:c??a,setSelectedPrivilege:s})})]}):O.jsx(U4,{tab:"Privilege"})]})},hce=({privileges:e,selectedPrivilege:t,setSelectedPrivilege:r})=>{const[n,i]=C.useState(!1);return O.jsx(pe.Panel,{path:pe.ROLES_TAB_PATH,isOpen:n,onOpen:()=>i(!0),onClose:()=>i(!1),children:O.jsx("div",{className:"flex h-full w-full min-h-0 px-3 pb-3",children:O.jsx(br,{depth:2,className:"h-full w-full overflow-hidden rounded",children:O.jsx(oae,{dict:e,data:pe.getGraphData(t.id,e),onSelect:o=>r(e[o])})})})})},pce=C.memo(({role:e})=>{var E;const t=Tr(),[r,n]=C.useState(e),[i,o]=C.useState(e.role),[a,s]=C.useState(null),c=t.getPrivileges(),d=((E=r.privileges)==null?void 0:E.filter(I=>c[I]&&c[I].privilege!=="guest").length)||0,u=t.getRoles(),{selectedRole:h,selectRole:p}=cS(),[v,y]=C.useState(!1),m=pe.useOutsideClick(()=>{v&&w()});pe.useDidMountEffect(()=>{i!==e.role&&o(e.role)},[e.role]),C.useEffect(()=>{e.role||y(!0)},[]),C.useEffect(()=>{n(e)},[e]);const g=()=>{s(null),y(!0)},w=()=>{s(null),e.role&&e.role===i&&y(!1);try{const I=pe.saveRole({...r,role:i},u);t.actions.updateRoles(I),y(!1)}catch(I){s(I.message)}},x=async I=>{if(I.stopPropagation(),t.getHost()==="vscode"){_();return}const{confirmed:N}=await t.actions.openModal({title:"Delete Role",type:pe.ModalType.CONFIRM,color:pe.ModalColor.DANGER,message:"Are you sure you want to remove this Role?",icon:"FdWarningDanger"});N&&_()},_=()=>{const I=pe.removeRole(r.id,u),N=Object.keys(I);if(h!==r.id){t.actions.updateRoles(I);return}if(N.length===0)p(null);else{const T=Object.keys(u),M=T.indexOf(r.id),z=Math.max(0,M-1),j=T[z];M===0?p(N[0]):I[j]?p(j):p(N[0])}t.actions.updateRoles(I)},S=(I=null)=>{if(I&&I.stopPropagation(),!e.role){_();return}y(!1),o(e.role)};return O.jsx(O.Fragment,{children:O.jsxs(br,{depth:4,borderType:h===r.id?"primary":h!==r.id?"light":"default",className:an("rounded border p-2"),role:"button","data-cy":"privilegeCard",onClick:()=>{p(r.id)},ref:m,children:[O.jsx("div",{className:"flex items-center justify-between",children:O.jsxs("div",{className:"flex flex-1 items-center",children:[O.jsx("span",{className:"mr-4",children:O.jsx(pd,{className:"h-6 w-6"})}),v?O.jsxs(wt.Root,{color:a?"negative":"primary",className:"flex-1 mr-2",children:[O.jsx(wt.Group,{className:"border-input-focus-border",children:O.jsx(wt.Field,{type:"text",value:i,onChange:({target:{value:I}})=>{o(I)},onKeyDown:I=>{I.key==="Enter"&&w(),I.key==="Escape"&&S()},placeholder:"role",autoComplete:"off",autoFocus:!0})}),a&&O.jsx(wt.Message,{children:a})]}):O.jsx("span",{className:"inline-block grow overflow-hidden truncate whitespace-nowrap text-xs font-bold",title:i,children:r.role}),O.jsx("div",{className:an("justify-between ml-auto flex w-fit items-center gap-x-2"),children:v?O.jsxs(O.Fragment,{children:[O.jsx(Jt,{color:"white",variant:"ghost",onClick:w,children:O.jsx(_V,{className:"h-4 w-4"})}),O.jsx(Jt,{color:"white",variant:"ghost",onClick:S,children:O.jsx(ej,{className:"h-4 w-4"})})]}):O.jsxs(O.Fragment,{children:[O.jsx(Jt,{color:"white",variant:"ghost",onClick:g,children:O.jsx(cj,{className:"h-4 w-4"})}),O.jsx(Jt,{color:"white",variant:"ghost",onClick:I=>x(I),children:O.jsx(pj,{className:"h-4 w-4"})})]})})]})}),O.jsxs("span",{className:an("ml-10.75 py-1 text-xs"),children:[d," Privilege",d>1?"s":""]})]})})}),gL=(e,t)=>e?t[e]:null,WD=(e,t,r)=>{const n=gL(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},vce=()=>{const e=Tr(),t=e.getPrivileges(),r=e.getRoles(),{selectedRole:n}=cS(),i=gL(n,r),o=(c,d)=>d&&d.privileges.includes(c.id),a=C.useMemo(()=>Object.values(t).filter(c=>o(c,i)&&c.privilege!=="guest"),[t,i]),s=C.useMemo(()=>Object.values(t).filter(c=>!o(c,i)&&c.privilege!=="guest"),[t,i]);return O.jsxs(br,{depth:1,className:"w-full border-b p-4 ",children:[O.jsx("div",{className:"mb-4 flex items-center gap-x-5",children:O.jsx("h4",{className:"text-[13px] font-semibold ",children:"Privileges"})}),O.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[O.jsx(vu,{"data-cy":"item=>Permisions",className:"italic opacity-90",children:"guest"}),a.map((c,d)=>O.jsxs(vu,{"data-cy":"item=>Permisions",color:"primary",onClick:()=>{const u=WD(i.id,c.id,r);e.actions.updateRoles(u)},children:[c.privilege,O.jsx(Tu.FdPlus,{className:"rotate-45 transform"})]},d)),s.map((c,d)=>O.jsxs(vu,{"data-cy":"item=>Permisions",color:"dark",onClick:()=>{const u=WD(i.id,c.id,r);e.actions.updateRoles(u)},children:[c.privilege,O.jsx(Tu.FdPlus,{})]},d))]})]})},fd=(e,t,r,n=!1)=>{const i=e.applyTo,o=e.type===pe.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()},d=h=>{h.forEach(p=>{a[p]&&(a[p].resources.forEach(v=>{if(v.resource===i||v.resource===o){const y=fd(e,t,{[p]:a[p]},n);Object.values(v.permissions).forEach(m=>{c[m.name].explicitly||(!c[m.name].from.includes(a[p].privilege)&&m.checked&&c[m.name].from.push(a[p].privilege),c[m.name].inherited=c[m.name].inherited||y[m.name].value||y[m.name].inherited)})}}),a[p].includes.length>0&&d(a[p].includes))})};if(Object.values(r).forEach(h=>{h.resources.forEach(p=>{p.resource===i&&Object.values(p.permissions).forEach(v=>{v.checked&&(c[v.name].explicitly=!0,n&&(c[v.name].value=!0))})}),(h.includes.length>0||h.privilege==="guest")&&d(h.includes)}),Object.values(t).forEach(h=>{h.resources.forEach(p=>{p.resource===i&&(h.privilege==="guest"?Object.values(p.permissions).forEach(v=>{v.checked&&(c[v.name].explicitly=!0,n&&(c[v.name].value=!0))}):Object.values(p.permissions).forEach(v=>{!c[v.name].explicitly&&v.checked&&(n?c[v.name].value=!0:c[v.name].value=!1)}))})}),(n?Object.entries(c).some(([h,p])=>h!=="promote"&&!p.value&&!p.explicitly):Object.entries(c).some(([h,p])=>h!=="promote"&&p.value&&!p.explicitly))&&![pe.EPermissionType.DATASTORE,pe.EPermissionType.SINGLETON].includes(e.type)){const h={applyTo:o,type:e.type===pe.EPermissionType.DATACLASS?pe.EPermissionType.DATASTORE:e.type===pe.EPermissionType.SINGLETON_METHOD?pe.EPermissionType.SINGLETON:pe.EPermissionType.DATACLASS},p=fd(h,t,r,n),v=y=>{let m=c[y].value;return n?!c[y].value&&!c[y].explicitly&&(m=p[y].value):c[y].value&&!c[y].explicitly&&(m=p[y].value),{value:m,inherited:c[y].inherited||p[y].inherited,from:c[y].from.length>0?c[y].from:p[y].from,explicitly:c[y].explicitly}};return{read:v("read"),create:v("create"),update:v("update"),drop:v("drop"),execute:v("execute"),promote:v("promote")}}return{read:c.read,create:c.create,update:c.update,drop:c.drop,execute:c.execute,promote:c.promote}},gce=({children:e})=>O.jsx("div",{className:"h-full w-full",children:O.jsx("div",{className:"flex h-full w-full flex-1 items-center justify-center",children:O.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-4 py-4 text-inactive-text",children:[O.jsx(on,{className:"absolute -right-full h-10 w-10 translate-x-1"}),O.jsx("div",{className:"text-center text-sm",children:e})]})})}),mce=e=>{switch(e){case"dataclass":return O.jsx(Pu,{className:"h-6 w-6"});case"singleton":return O.jsx(fj,{className:"h-6 w-6"});case"datastore":return O.jsx(lj,{className:"h-6 w-6"});case"attribute":return O.jsx(hj,{className:"h-6 w-6"});case"method":return O.jsx(tj,{className:"h-6 w-6"});case"singletonMethod":return O.jsx(sj,{className:"h-6 w-6"});case"entityselMethod":return O.jsx(aj,{className:"h-6 w-6"});case"entityMethod":return O.jsx(oj,{className:"h-6 w-6"});case"dsMethod":return O.jsx(ij,{className:"h-6 w-6"});case"dataclassMethod":return O.jsx(nj,{className:"h-6 w-6"});default:return O.jsx(Pu,{className:"h-6 w-6"})}},UD=({privileges:e,permission:t,hasChild:r,depth:n,isChild:i=!1,className:o,inSearch:a,toggleCollapse:s,collapsed:c,isRestrictedByDefault:d,toastMessageCallback:u,computedInherited:h})=>{const[p,v]=t.applyTo.split("."),y=C.useMemo(()=>h||fd(t,e.otherPrivs,e.rolePrivs,d),[h,e,t,d]);return O.jsxs("tr",{className:an("group even:bg-white/5 hover:bg-input-bg",o),children:[O.jsxs("td",{className:an("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((m,g)=>O.jsx("div",{className:an("ml-1.5 mr-1 w-[2px] bg-muted",{"mr-0.5":i})},g)),O.jsxs("div",{className:"flex items-center gap-3 py-2",children:[r&&O.jsx("button",{onClick:s,className:"w-3",children:c?O.jsx(uj,{className:"inline h-4 w-4"}):O.jsx(rj,{className:"inline h-4 w-4"})}),mce(t.type),a?t.applyTo:v||p]})]}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[pe.EPermissionType.ATTRIBUTE,pe.EPermissionType.DATASTORE,pe.EPermissionType.DATACLASS].includes(t.type)&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.read.value||y.read.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.read.value&&y.read.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.read.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.read.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[pe.EPermissionType.ATTRIBUTE,pe.EPermissionType.DATASTORE,pe.EPermissionType.DATACLASS].includes(t.type)&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.create.value||y.create.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.create.value&&y.create.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.read.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.read.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[pe.EPermissionType.ATTRIBUTE,pe.EPermissionType.DATASTORE,pe.EPermissionType.DATACLASS].includes(t.type)&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.update.value||y.update.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.update.value&&y.update.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.update.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.update.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[pe.EPermissionType.ATTRIBUTE,pe.EPermissionType.DATASTORE,pe.EPermissionType.DATACLASS].includes(t.type)&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.drop.value||y.drop.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.drop.value&&y.drop.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.drop.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.drop.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})}),O.jsx("td",{className:"py-2 text-center group-hover:rounded-r group-hover:bg-input-bg",children:t.type!=="attribute"&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.execute.value||y.execute.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.execute.value&&y.execute.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.execute.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.execute.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})})]})};function GD(e,t,r){const n=[],i=(a,s,c)=>n.push({id:a,permission:s,depth:c,hasChild:!1,isChild:!1}),o=(a,s,c,d,u,h)=>{n.push({id:a,permission:s,depth:c,hasChild:!0,isChild:d,toggleId:a,isCollapsed:u}),u||h()};for(const a of Object.values(e)){o("ds-group",{applyTo:a.applyTo,type:a.type},0,!1,t,()=>{for(const s of a.methods)i(`dsm-${s.applyTo}`,s,1);for(const s of a.dataClasses){const c=`dc-${s.applyTo}`;o(c,{applyTo:s.applyTo,type:s.type},1,!0,r[c]??!1,()=>{for(const d of s.attributes)i(`dca-${d.applyTo}`,d,2);for(const d of s.methods)i(`dcm-${d.applyTo}`,d,2)})}});for(const s of a.singletons){const c=`sing-${s.applyTo}`;o(c,{applyTo:s.applyTo,type:s.type},0,!0,r[c]??!1,()=>{for(const d of s.attributes)i(`singa-${d.applyTo}`,d,1);for(const d of s.methods)i(`singm-${d.applyTo}`,d,1)})}}return n}const KD=["datastore","singleton","dataclass","attribute","dsMethod","dataclassMethod","entityMethod","entityselMethod","singletonMethod"],yo={datastore:["datastore"],dataclass:["dataclass"],singleton:["singleton"],functions:["method","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"],attribute:["attribute"]},YD=Object.values(yo).flat();function pa(e,t){return t.length>0&&t.every(r=>e.includes(r))}function bce(e,t){return Array.from(new Set([...e,...t]))}function yce(e,t){return e.filter(r=>!t.includes(r))}const xce=({selectedRole:e})=>{const[t,r]=C.useState(null),[n,i]=C.useState(null),{styles:o,attributes:a}=Cd(t,n,{modifiers:[{name:"offset",options:{offset:[0,10]}}]}),s=Tr(),c=s.getRestrictedByDefault(),d=s.getPrivileges(),[u,h]=C.useState([]),[p,v]=C.useState([]),[y,m]=C.useState(""),[g,w]=C.useState("");C.useEffect(()=>{const J=setTimeout(()=>v(u),0);return()=>clearTimeout(J)},[u]);const x=s.getCatalogMethods(),_=s.getDataclasses(),S=s.getSingletons(),E=C.useMemo(()=>sae(x,Object.values(_),Object.values(S)),[x,_,S]),I=C.useMemo(()=>!p.length&&!g?[]:[...US(g,x,Object.values(_),Object.values(S))].filter(J=>p.length?p.includes(J.type):!0).sort((J,ae)=>{const he=KD.indexOf(J.type),ue=KD.indexOf(ae.type);return he!==ue?he-ue:J.applyTo.toLowerCase()>ae.applyTo.toLowerCase()?1:-1}),[g,p,x,_,S]),N=J=>h([...J]),T=J=>{h(ae=>pa(ae,J)?yce(ae,J):bce(ae,J))},M=J=>T(yo[J]),z=YD.every(J=>u.includes(J)),j=u.length>0&&!z,W=pa(u,yo.functions),U=()=>N(YD),A=()=>N([]),K=s.getRoles(),[V,te]=C.useState(K);C.useEffect(()=>{const J=setTimeout(()=>te(K),0);return()=>clearTimeout(J)},[K]);const G=C.useRef(null);C.useEffect(()=>{var J,ae;(ae=(J=G.current)==null?void 0:J.getScrollElement())==null||ae.scrollTo({top:0})},[e]);const re=cd({count:I.length,getScrollElement:()=>{var J;return((J=G.current)==null?void 0:J.getScrollElement())??null},estimateSize:()=>36,overscan:5,paddingEnd:40}),P=C.useMemo(()=>{const J=Object.values(d).find(le=>le.privilege==="guest"),ae=V[e],he=ae?Object.fromEntries(ae.privileges.map(le=>[le,d[le]]).filter(([,le])=>!!le)):{};if(c)return{rolePrivs:he,otherPrivs:J?{[J.id]:J}:{}};const ue=J?{[J.id]:{...J,active:!0}}:{},de=Object.fromEntries(Object.entries(d).filter(([le])=>le!==(J==null?void 0:J.id)&&!(ae!=null&&ae.privileges.includes(le))).map(([le,xe])=>[le,{...xe,active:!1}]));return{rolePrivs:he,otherPrivs:{...ue,...de}}},[d,V,e,c]),[B,X]=C.useState(!1),[Q,D]=C.useState({}),$=C.useMemo(()=>{const J=[];for(const ae of Object.values(E)){for(const he of ae.dataClasses)J.push(`dc-${he.applyTo}`);for(const he of ae.singletons)J.push(`sing-${he.applyTo}`)}return J},[E]),H=$.length>0&&$.every(J=>Q[J]===!0),q=C.useCallback(()=>{const J={};for(const ae of $)J[ae]=!0;D(J)},[$]),Y=C.useCallback(J=>{J==="ds-group"?X(ae=>!ae):D(ae=>({...ae,[J]:!ae[J]}))},[]),ie=C.useMemo(()=>{const J=new Map;for(const{permission:ae}of GD(E,!1,{}))J.set(`${ae.applyTo}|${ae.type}`,fd(ae,P.otherPrivs,P.rolePrivs,c));return J},[P,c,E]),ne=C.useMemo(()=>GD(E,B,Q),[E,B,Q]),ve=cd({count:ne.length,getScrollElement:()=>{var J;return((J=G.current)==null?void 0:J.getScrollElement())??null},estimateSize:()=>36,overscan:8,paddingEnd:15}),Z=C.useCallback(()=>{pe.toastSubject.next({kind:"info",markdown:!0,message:"**Info:** You can add or modify permissions only in the Privilege section.",customIcon:Ew})},[]);return O.jsxs(hf,{ref:G,className:"z-20 h-full flex-1 overflow-auto p-3.75 pt-0",style:{maxHeight:"calc(100vh - 5.5rem - 85px - 20px)"},children:[O.jsxs("table",{className:"relative h-full w-full border-collapse",children:[O.jsx("thead",{className:"sticky top-0 z-20 bg-panel-1",children:O.jsxs("tr",{className:"border-b border-grey-100",children:[O.jsx("td",{className:"py-2",children:O.jsxs("div",{className:"flex items-center gap-x-2",children:[O.jsx(Lr,{label:"Collapse All",position:"up",container:Br(),children:O.jsx(Jt,{color:"white",variant:"ghost",disabled:B&&H,onClick:()=>{H?(q(),X(!0)):q()},children:O.jsx(yV,{})})}),O.jsx(wt.Root,{className:"w-56",children:O.jsxs(wt.Group,{children:[O.jsx(wt.Icon,{children:O.jsx(dj,{})}),O.jsx(wt.Field,{type:"text",placeholder:"Search",value:y,onChange:J=>{const ae=J.target.value;m(ae),setTimeout(()=>w(ae),0)}}),O.jsx(wn.Popover,{className:"flex items-center",children:({open:J})=>O.jsxs(O.Fragment,{children:[O.jsx(wn.Popover.Button,{ref:r,children:O.jsx(wt.Icon,{isAction:!0,children:O.jsx(JD,{})})}),J&&O.jsx(ef,{children:O.jsx(wn.Popover.Panel,{ref:i,style:o.popper,...a.popper,className:"z-50",static:!0,children:O.jsxs(br,{depth:3,borderType:"light",className:"rounded-md border px-4 py-2.5 text-xs",children:[O.jsxs("label",{className:"mb-2 flex cursor-pointer items-center gap-2",children:[O.jsx(ir,{size:"sm",value:j?null:z,onChange:()=>z?A():U()}),O.jsx("h5",{className:"text-sm font-semibold",children:"Filter"})]}),O.jsxs("div",{className:"space-y-2 text-s",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:pa(u,yo.datastore),onChange:()=>M("datastore"),label:"Datastore"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:pa(u,yo.dataclass),onChange:()=>M("dataclass"),label:"Dataclass"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:pa(u,yo.singleton),onChange:()=>M("singleton"),label:"Singleton"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:W,onChange:()=>M("functions"),label:"Functions"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:pa(u,yo.attribute),onChange:()=>M("attribute"),label:"Attribute"})})]})]})})})]})})]})})]})}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"read"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Create"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Update"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Delete"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Execute"})]})}),O.jsx("tbody",{className:"relative",children:p.length||g?O.jsxs(O.Fragment,{children:[re.getVirtualItems().length>0?O.jsx("tr",{style:{height:`${re.getVirtualItems()[0].start}px`},children:O.jsx("td",{colSpan:6})}):null,re.getVirtualItems().map(J=>{const ae=I[J.index];return O.jsx(UD,{privileges:P,permission:ae,depth:0,inSearch:!0,isRestrictedByDefault:c,allPrivileges:d,toastMessageCallback:Z,computedInherited:ie.get(`${ae.applyTo}|${ae.type}`)},`${ae.type}-${J.index}`)}),(()=>{const J=re.getVirtualItems();if(!J.length)return null;const ae=re.getTotalSize()-J[J.length-1].end;return ae>0?O.jsx("tr",{style:{height:`${ae}px`},children:O.jsx("td",{colSpan:6})}):null})()]}):O.jsxs(O.Fragment,{children:[ve.getVirtualItems().length>0?O.jsx("tr",{style:{height:`${ve.getVirtualItems()[0].start}px`},children:O.jsx("td",{colSpan:6})}):null,ve.getVirtualItems().map(J=>{const ae=ne[J.index];return O.jsx(UD,{privileges:P,permission:ae.permission,depth:ae.depth,hasChild:ae.hasChild,isChild:ae.isChild,collapsed:ae.isCollapsed,toggleCollapse:ae.toggleId?()=>Y(ae.toggleId):void 0,isRestrictedByDefault:c,allPrivileges:d,toastMessageCallback:Z,computedInherited:ie.get(`${ae.permission.applyTo}|${ae.permission.type}`)},ae.id)}),(()=>{const J=ve.getVirtualItems();if(!J.length)return null;const ae=ve.getTotalSize()-J[J.length-1].end;return ae>0?O.jsx("tr",{style:{height:`${ae}px`},children:O.jsx("td",{colSpan:6})}):null})()]})})]}),(g||p.length)&&!I.length?O.jsx(gce,{children:"The Permission you're looking for can't be found "}):null]})},wce=()=>O.jsx("div",{className:"flex flex-1 items-center justify-center",children:O.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-grey-200 border-t-primary-dark"})}),Sce=()=>{const e=Tr(),t=e.getRoles(),[r,n]=C.useState(null),[i,o]=C.useState(null),[a,s]=C.useState(""),[c,d]=C.useState(null),{styles:u,attributes:h}=Cd(r,i,{modifiers:[{name:"offset",options:{offset:[-10,10]}}],placement:"right-start"});C.useEffect(()=>{s(""),d(null)},[i]);const p=()=>{if(!a)throw new Error("Please enter a valid name");if(Object.values(t).find(g=>g.role.toLowerCase()===a.toLowerCase()))throw new Error(`A role with the name ${a} already exists`);const y=yz.generate(),m=pe.createRole(y,a,t);e.actions.updateRoles(m)};return O.jsx(wn.Popover,{children:({open:v,close:y})=>{const m=()=>{d(null);try{pe.validateName(a),p(),y()}catch(g){d(g.message)}};return O.jsxs(O.Fragment,{children:[O.jsx(wn.Popover.Button,{className:"rounded","data-cy":"New-priv-btn",as:"div",ref:n,children:O.jsx(Jt,{variant:"ghost",color:"white",children:O.jsx(ja,{className:"h-4 w-4"})})}),v&&O.jsx(ef,{children:O.jsx(wn.Popover.Panel,{ref:o,style:u.popper,...h.popper,"data-cy":"New-priv-pop-up",className:"z-50",static:!0,children:O.jsxs(br,{className:"min-w-[256px] border rounded px-4 py-2 text-xs shadow-md",depth:3,borderType:"light",children:[O.jsx("h5",{className:"mb-2 text-xs font-semibold",children:"Create New Role"}),O.jsx("div",{className:"mt-2",children:O.jsxs("label",{className:"flex items-center gap-x-4",children:[O.jsx("span",{children:"Name"}),O.jsx(wt.Root,{color:c?"negative":"primary",className:"w-full",children:O.jsxs(wt.Group,{children:[c&&O.jsx(wt.Message,{children:c}),O.jsx(wt.Field,{autoFocus:!0,value:a,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m()},type:"text"})]})})]})}),O.jsxs("div",{className:"mt-4 flex items-center justify-center gap-x-2",children:[O.jsx(Jt,{onClick:()=>{m()},children:"Create"}),O.jsx(Jt,{color:"white",variant:"outline",onClick:()=>y(),children:"Cancel"})]})]})})})]})}})},Ece=()=>{const e=Tr(),t=e.getRoles(),r=e.getPrivileges(),{selectedRole:n,deferredSelectedRole:i}=cS(),o=C.useMemo(()=>Object.values(t).sort((a,s)=>pe.localeCompare(a.role,s.role)),[t]);return O.jsxs("div",{className:"flex flex-1 h-full",children:[O.jsxs(br,{depth:1,className:"flex h-full w-89 flex-col border-r",children:[O.jsxs("div",{className:"flex shrink-0 items-center justify-between px-3.5 py-2.5",children:[O.jsxs("div",{className:"flex items-center gap-x-1",children:[O.jsx("span",{children:O.jsx(pd,{className:"h-3.5 w-3.5"})}),O.jsx("span",{className:"text-[11px] font-semibold",children:"Roles"})]}),O.jsx(Sce,{})]}),O.jsx("div",{className:"flex-1 overflow-auto p-4 pb-10 pt-1",children:o.length>0?O.jsx("div",{className:"flex flex-col gap-4",children:o.map(a=>O.jsx(pce,{role:a,privileges:r},a.id))}):O.jsx("div",{className:"flex h-full items-center justify-center",children:O.jsx("div",{className:"flex flex-1 items-center justify-center text-inactive-text",children:O.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-4",children:[O.jsx(on,{className:"h-10 w-10"}),O.jsx("div",{className:"font-semibold",children:"There are no roles"}),O.jsxs("div",{className:"flex items-center text-sm",children:["Create a new role by clicking on the"," ",O.jsx(ja,{className:"ml-2 inline h-4 w-4"})]})]})})})})]}),O.jsx(br,{depth:1,className:an("relative flex h-full w-full flex-1 flex-col items-stretch overflow-x-auto",{"border-l-[0.5px]":n}),children:O.jsx("div",{className:"flex h-full w-full select-none flex-col",children:n?O.jsxs(O.Fragment,{children:[O.jsx(vce,{}),i?O.jsx(xce,{selectedRole:i}):O.jsx(wce,{})]}):O.jsx(U4,{tab:"Role"})})})]})},mL=()=>{const e=Tr(),t=e.getQodly(),r=e.getSelectedTab(),n=e.getForceLogin(),i=e.getRestrictedByDefault(),{canUndo:o,canRedo:a}=e.getHistory(),s=C.useRef();return O.jsx("div",{className:"absolute inset-0 flex flex-1 overflow-hidden",children:O.jsx("div",{className:"relative flex flex-1 overflow-hidden","data-cy":"Roles&Privileges-editor-cy",ref:c=>s.current=c,children:O.jsxs("div",{className:"flex min-h-0 w-full flex-1 flex-col",children:[O.jsx($Y,{activeTab:r,forceLogin:n,restrictedByDefault:i,canUndo:o,canRedo:a,onUndo:e.actions.undo,onRedo:e.actions.redo,onTabChange:c=>{e.actions.toggleTab(c)},onForceLoginChange:c=>{e.actions.toggleForceLogin(c)},onRestrictedByDefaultChange:c=>{e.actions.toggleRestrictedByDefault(c)},qodly:t}),O.jsx("div",{className:r==="roles"?"flex flex-1 overflow-hidden":"hidden",children:O.jsx(VY,{children:O.jsx(Ece,{})})}),O.jsx("div",{className:r==="privileges"?"flex flex-1 overflow-hidden":"hidden",children:O.jsx(fce,{})})]})})})},_ce="object",Oce={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"}}}}},Cce={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"]},PermissionEntry:{type:"array",items:{type:"string"}},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:{$ref:"#/definitions/PermissionEntry"},create:{$ref:"#/definitions/PermissionEntry"},update:{$ref:"#/definitions/PermissionEntry"},drop:{$ref:"#/definitions/PermissionEntry"},execute:{$ref:"#/definitions/PermissionEntry"},promote:{$ref:"#/definitions/PermissionEntry"}},required:["applyTo","type"]}},Ice={type:_ce,properties:Oce,definitions:Cce},Rce=()=>{const{modals:e,closeModal:t,editModal:r}=Kae();return O.jsx(O.Fragment,{children:e.map((n,i)=>O.jsx(pe.Modal,{hasOverlay:i===0,...n,onClose:t,onEdit:r,container:Br()},n.id))})},bL=e=>{if(!e)return pe.rolesToAPI(pe.sanitizeRoles({}));try{return pe.rolesToAPI(pe.sanitizeRoles(JSON.parse(e)))}catch{return pe.rolesToAPI(pe.sanitizeRoles({}))}},Nce=({initialValue:e,onChange:t,...r})=>{const n=Tr(),i=n.getRolesFlags(),o=n.getRolesAndPrivileges(),a=C.useMemo(()=>bL(e),[e]),s=C.useRef(o),c=C.useRef(a),d=C.useRef(a);return C.useEffect(()=>{s.current=o},[o]),C.useEffect(()=>{Xi.isEqual(a,d.current)||(d.current=a,c.current=a,!Xi.isEqual(a,s.current)&&n.actions.setRolesContent({content:a,flags:{touched:!1}}))},[n,a]),pe.useDidMountEffect(()=>{if(!(!t||!i.touched)&&!Xi.isEqual(o,c.current))try{const u=JSON.stringify(o,null,2);t(u),c.current=o}catch(u){console.error("[Roles Editor Standalone] Error on value stringify:",u)}},[o,i.touched,t]),O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"relative h-screen z-10 overflow-hidden",children:O.jsx(mL,{...r})}),O.jsx(Rce,{})]})},Tce=e=>{const t=Gae();return O.jsx(dz,{adapter:t,children:O.jsx(pe.TipsProvider,{children:O.jsx(Nce,{...e})})})},Pce=({initialValue:e,catalog:t,history:r,...n})=>{const i=C.useMemo(()=>({...pe.sanitizeRoles(bL(e)),flags:{touched:!1}}),[e]);return O.jsx(Uae,{initialState:i,catalog:t,history:r,children:O.jsx(Tce,{initialValue:e,...n})})};exports.ROLES_EDITOR_SCOPE_CLASS=XD.ROLES_EDITOR_SCOPE_CLASS;exports.EditorStateAdapterProvider=dz;exports.Roles=mL;exports.Standalone=Pce;exports.jsonSchema=Ice;exports.useReduxAdapter=fae;
|
|
119
|
+
ressources`,container:Br(),children:O.jsx(Jt,{color:"white",variant:"ghost",onClick:P,children:O.jsx(SV,{})})})}),O.jsx(Lr,{icon:O.jsx(wi,{}),label:"Delete all the non existing resources from privileges",container:Br(),children:O.jsx(Jt,{color:"white",variant:"ghost",onClick:q,disabled:!H,children:O.jsx(QD,{className:"h-4 w-4"})})})]})}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Read"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Create"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Update"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Delete"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Execute"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Promote"})]})}),D.length?O.jsxs("tbody",{children:[ie.getVirtualItems().length>0?O.jsx("tr",{style:{height:`${ie.getVirtualItems()[0].start}px`},children:O.jsx("td",{colSpan:7})}):null,ie.getVirtualItems().map(Z=>{const J=D[Z.index],ae=J.permissions.some(he=>he.from.length>0);return O.jsxs("tr",{className:an("group even:bg-white/5 hover:bg-input-bg",{"opacity-60":J.exists===!1}),children:[O.jsxs("td",{className:an("group flex items-center gap-3 py-2 text-xs group-hover:rounded-l group-hover:bg-input-bg ",J.exists===!1?"text-negative-text":""),children:[vL(J.type),J.resource,O.jsx(Lr,{label:"Remove Permission",container:Br(),children:O.jsx(Jt,{color:"white",variant:"ghost",disabled:ae,onClick:()=>{ae?pe.toastSubject.next({kind:"info",markdown:!0,message:"**Info:** Inherited permissions can't be removed",customIcon:on}):re({applyTo:J.resource,type:J.type})},className:"opacity-0 group-hover:opacity-100",children:O.jsx(ja,{className:"h-4 w-4 rotate-45 transform"})})})]}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"read",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|read`]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"create",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|create`]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg ",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"update",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|update`]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"drop",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|drop`]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:O.jsx(fa,{promoted:M[J.resource],permissions:J.permissions,showIncluded:r,label:"execute",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|execute`]})}),O.jsx("td",{className:"py-2 text-center group-hover:rounded-r group-hover:bg-input-bg",children:O.jsx(fa,{permissions:J.permissions,showIncluded:r,label:"promote",onToggle:he=>$(J,he),onSelect:t,privileges:n,exists:J.exists,optimisticChecked:S[`${J.resource}|${J.type}|promote`]})})]},`${J.resource}-${Z.index}`)}),(()=>{const Z=ie.getVirtualItems();if(!Z.length)return null;const J=ie.getTotalSize()-Z[Z.length-1].end;return J>0?O.jsx("tr",{style:{height:`${J}px`},children:O.jsx("td",{colSpan:7})}):null})()]}):null]}),!Q.length&&x?O.jsx(VD,{children:"The Permission you're looking for can't be found "}):null,!Q.length&&!x?O.jsxs(VD,{children:["This Privilege has no Permissions configured yet ",O.jsx("br",{}),'Add a new permission by using the "Create a permission" input above']}):null]})},dce=({onCreate:e})=>{const t=Tr(),r=t.getPrivileges(),[n,i]=C.useState(null),[o,a]=C.useState(null),[s,c]=C.useState(""),[d,u]=C.useState(null),{styles:h,attributes:p}=Cd(n,o,{modifiers:[{name:"offset",options:{offset:[-10,10]}}],placement:"right-start"});C.useEffect(()=>{c(""),u(null)},[o]);const v=(y=()=>{})=>{u(null);try{const m=pe.createPrivilege(s,r),g=Object.values(m).find(w=>w.privilege===s);t.actions.updatePrivileges(m),g&&e(g),setTimeout(()=>{y()},0)}catch(m){u(m.message)}};return O.jsx(wn.Popover,{children:({open:y,close:m})=>O.jsxs(O.Fragment,{children:[O.jsx(wn.Popover.Button,{className:"rounded","data-cy":"New-priv-btn",as:"div",ref:i,children:O.jsx(Jt,{variant:"ghost",color:"white",children:O.jsx(ja,{className:"h-4 w-4"})})}),y&&O.jsx(ef,{children:O.jsx(wn.Popover.Panel,{ref:a,style:h.popper,...p.popper,"data-cy":"New-priv-pop-up",className:"z-50",static:!0,children:O.jsxs(br,{className:"min-w-[256px] border rounded px-4 py-2 text-xs shadow-md",depth:3,borderType:"light",children:[O.jsx("h5",{className:"mb-2 text-xs font-semibold",children:"Create New Privilege"}),O.jsx("div",{className:"mt-2",children:O.jsxs("label",{className:"flex items-center gap-x-4",children:[O.jsx("span",{children:"Name"}),O.jsx(wt.Root,{className:"w-full",color:d?"negative":"primary",children:O.jsxs(wt.Group,{children:[d&&O.jsx(wt.Message,{children:d}),O.jsx(wt.Field,{autoFocus:!0,value:s,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Enter"&&v()},type:"text"})]})})]})}),O.jsxs("div",{className:"mt-4 flex items-center justify-center gap-x-2",children:[O.jsx(Jt,{onClick:()=>v(m),children:"Create"}),O.jsx(Jt,{color:"white",variant:"outline",onClick:()=>m(),children:"Cancel"})]})]})})})]})})},fce=()=>{const e=Tr(),t=e.getCatalog(),r=e.getPrivileges(),[n,i]=C.useState(r);C.useEffect(()=>{const y=setTimeout(()=>i(r),0);return()=>clearTimeout(y)},[r]);const o=C.useMemo(()=>{if(t===null)return n;const y=sz(n,Object.values((t==null?void 0:t.dataClasses)??{}));return lz(y,t)},[n,t]),[a,s]=C.useState(null),[c,d]=C.useState(null),u=y=>{s(y),setTimeout(()=>d(y),0)},h=C.useMemo(()=>Object.keys(o),[o]);C.useEffect(()=>{if(a&&o[a.id]||!h.length)return;const y=o[h[0]];s(y),d(y)},[o]),C.useEffect(()=>{h.length<2&&v(!0)},[h.length]);const[p,v]=C.useState(!0);return O.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-1",children:[O.jsxs(br,{depth:1,className:"flex h-full w-89 shrink-0 flex-col border-r",children:[O.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between px-3.5 py-2.5",children:[O.jsxs("div",{className:"flex items-center gap-x-1",children:[O.jsx("span",{children:O.jsx(pd,{className:"h-3.5 w-3.5"})}),O.jsx("span",{className:"text-[11px] font-semibold",children:"Privileges"})]}),O.jsx(dce,{onCreate:y=>{s(y),d(y)}})]}),O.jsx(lse,{privileges:o,selectedPrivilege:a,selectPrivilege:u})]}),a&&o[a.id]?O.jsxs(br,{depth:1,className:"privileges-container relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden border-l-[0.5px]",children:[O.jsxs("div",{className:"mb-1 flex min-h-0 min-w-0 flex-1 h-full w-full flex-col items-stretch overflow-auto",children:[(c??a).privilege!=="guest"?O.jsx(Yae,{privileges:o,selectedPrivilege:c??a,onSelect:y=>s(r[y]),setShowIncluded:v,showIncluded:p}):null,O.jsx(uce,{privileges:o,rawPrivileges:r,selectedPrivilege:c??a,onSelect:y=>s(r[y]),showIncluded:p})]}),O.jsx("div",{className:"mt-auto flex-shrink-0",children:O.jsx(hce,{privileges:o,selectedPrivilege:c??a,setSelectedPrivilege:s})})]}):O.jsx(U4,{tab:"Privilege"})]})},hce=({privileges:e,selectedPrivilege:t,setSelectedPrivilege:r})=>{const[n,i]=C.useState(!1);return O.jsx(pe.Panel,{path:pe.ROLES_TAB_PATH,isOpen:n,onOpen:()=>i(!0),onClose:()=>i(!1),children:O.jsx("div",{className:"flex h-full w-full min-h-0 px-3 pb-3",children:O.jsx(br,{depth:2,className:"h-full w-full overflow-hidden rounded",children:O.jsx(oae,{dict:e,data:pe.getGraphData(t.id,e),onSelect:o=>r(e[o])})})})})},pce=C.memo(({role:e})=>{var E;const t=Tr(),[r,n]=C.useState(e),[i,o]=C.useState(e.role),[a,s]=C.useState(null),c=t.getPrivileges(),d=((E=r.privileges)==null?void 0:E.filter(I=>c[I]&&c[I].privilege!=="guest").length)||0,u=t.getRoles(),{selectedRole:h,selectRole:p}=cS(),[v,y]=C.useState(!1),m=pe.useOutsideClick(()=>{v&&w()});pe.useDidMountEffect(()=>{i!==e.role&&o(e.role)},[e.role]),C.useEffect(()=>{e.role||y(!0)},[]),C.useEffect(()=>{n(e)},[e]);const g=()=>{s(null),y(!0)},w=()=>{s(null),e.role&&e.role===i&&y(!1);try{const I=pe.saveRole({...r,role:i},u);t.actions.updateRoles(I),y(!1)}catch(I){s(I.message)}},x=async I=>{if(I.stopPropagation(),t.getHost()==="vscode"){_();return}const{confirmed:N}=await t.actions.openModal({title:"Delete Role",type:pe.ModalType.CONFIRM,color:pe.ModalColor.DANGER,message:"Are you sure you want to remove this Role?",icon:"FdWarningDanger"});N&&_()},_=()=>{const I=pe.removeRole(r.id,u),N=Object.keys(I);if(h!==r.id){t.actions.updateRoles(I);return}if(N.length===0)p(null);else{const T=Object.keys(u),M=T.indexOf(r.id),z=Math.max(0,M-1),j=T[z];M===0?p(N[0]):I[j]?p(j):p(N[0])}t.actions.updateRoles(I)},S=(I=null)=>{if(I&&I.stopPropagation(),!e.role){_();return}y(!1),o(e.role)};return O.jsx(O.Fragment,{children:O.jsxs(br,{depth:4,borderType:h===r.id?"primary":h!==r.id?"light":"default",className:an("rounded border p-2"),role:"button","data-cy":"privilegeCard",onClick:()=>{p(r.id)},ref:m,children:[O.jsx("div",{className:"flex items-center justify-between",children:O.jsxs("div",{className:"flex flex-1 items-center",children:[O.jsx("span",{className:"mr-4",children:O.jsx(pd,{className:"h-6 w-6"})}),v?O.jsxs(wt.Root,{color:a?"negative":"primary",className:"flex-1 mr-2",children:[O.jsx(wt.Group,{className:"border-input-focus-border",children:O.jsx(wt.Field,{type:"text",value:i,onChange:({target:{value:I}})=>{o(I)},onKeyDown:I=>{I.key==="Enter"&&w(),I.key==="Escape"&&S()},placeholder:"role",autoComplete:"off",autoFocus:!0})}),a&&O.jsx(wt.Message,{children:a})]}):O.jsx("span",{className:"inline-block grow overflow-hidden truncate whitespace-nowrap text-xs font-bold",title:i,children:r.role}),O.jsx("div",{className:an("justify-between ml-auto flex w-fit items-center gap-x-2"),children:v?O.jsxs(O.Fragment,{children:[O.jsx(Jt,{color:"white",variant:"ghost",onClick:w,children:O.jsx(_V,{className:"h-4 w-4"})}),O.jsx(Jt,{color:"white",variant:"ghost",onClick:S,children:O.jsx(ej,{className:"h-4 w-4"})})]}):O.jsxs(O.Fragment,{children:[O.jsx(Jt,{color:"white",variant:"ghost",onClick:g,children:O.jsx(cj,{className:"h-4 w-4"})}),O.jsx(Jt,{color:"white",variant:"ghost",onClick:I=>x(I),children:O.jsx(pj,{className:"h-4 w-4"})})]})})]})}),O.jsxs("span",{className:an("ml-10.75 py-1 text-xs"),children:[d," Privilege",d>1?"s":""]})]})})}),gL=(e,t)=>e?t[e]:null,WD=(e,t,r)=>{const n=gL(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},vce=()=>{const e=Tr(),t=e.getPrivileges(),r=e.getRoles(),{selectedRole:n}=cS(),i=gL(n,r),o=(c,d)=>d&&d.privileges.includes(c.id),a=C.useMemo(()=>Object.values(t).filter(c=>o(c,i)&&c.privilege!=="guest"),[t,i]),s=C.useMemo(()=>Object.values(t).filter(c=>!o(c,i)&&c.privilege!=="guest"),[t,i]);return O.jsxs(br,{depth:1,className:"w-full border-b p-4 ",children:[O.jsx("div",{className:"mb-4 flex items-center gap-x-5",children:O.jsx("h4",{className:"text-[13px] font-semibold ",children:"Privileges"})}),O.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[O.jsx(vu,{"data-cy":"item=>Permisions",className:"italic opacity-90",children:"guest"}),a.map((c,d)=>O.jsxs(vu,{"data-cy":"item=>Permisions",color:"primary",onClick:()=>{const u=WD(i.id,c.id,r);e.actions.updateRoles(u)},children:[c.privilege,O.jsx(Tu.FdPlus,{className:"rotate-45 transform"})]},d)),s.map((c,d)=>O.jsxs(vu,{"data-cy":"item=>Permisions",color:"dark",onClick:()=>{const u=WD(i.id,c.id,r);e.actions.updateRoles(u)},children:[c.privilege,O.jsx(Tu.FdPlus,{})]},d))]})]})},fd=(e,t,r,n=!1)=>{const i=e.applyTo,o=e.type===pe.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()},d=h=>{h.forEach(p=>{a[p]&&(a[p].resources.forEach(v=>{if(v.resource===i||v.resource===o){const y=fd(e,t,{[p]:a[p]},n);Object.values(v.permissions).forEach(m=>{c[m.name].explicitly||(!c[m.name].from.includes(a[p].privilege)&&m.checked&&c[m.name].from.push(a[p].privilege),c[m.name].inherited=c[m.name].inherited||y[m.name].value||y[m.name].inherited)})}}),a[p].includes.length>0&&d(a[p].includes))})};if(Object.values(r).forEach(h=>{h.resources.forEach(p=>{p.resource===i&&Object.values(p.permissions).forEach(v=>{v.checked&&(c[v.name].explicitly=!0,n&&(c[v.name].value=!0))})}),(h.includes.length>0||h.privilege==="guest")&&d(h.includes)}),Object.values(t).forEach(h=>{h.resources.forEach(p=>{p.resource===i&&(h.privilege==="guest"?Object.values(p.permissions).forEach(v=>{v.checked&&(c[v.name].explicitly=!0,n&&(c[v.name].value=!0))}):Object.values(p.permissions).forEach(v=>{!c[v.name].explicitly&&v.checked&&(n?c[v.name].value=!0:c[v.name].value=!1)}))})}),(n?Object.entries(c).some(([h,p])=>h!=="promote"&&!p.value&&!p.explicitly):Object.entries(c).some(([h,p])=>h!=="promote"&&p.value&&!p.explicitly))&&![pe.EPermissionType.DATASTORE,pe.EPermissionType.SINGLETON].includes(e.type)){const h={applyTo:o,type:e.type===pe.EPermissionType.DATACLASS?pe.EPermissionType.DATASTORE:e.type===pe.EPermissionType.SINGLETON_METHOD?pe.EPermissionType.SINGLETON:pe.EPermissionType.DATACLASS},p=fd(h,t,r,n),v=y=>{let m=c[y].value;return n?!c[y].value&&!c[y].explicitly&&(m=p[y].value):c[y].value&&!c[y].explicitly&&(m=p[y].value),{value:m,inherited:c[y].inherited||p[y].inherited,from:c[y].from.length>0?c[y].from:p[y].from,explicitly:c[y].explicitly}};return{read:v("read"),create:v("create"),update:v("update"),drop:v("drop"),execute:v("execute"),promote:v("promote")}}return{read:c.read,create:c.create,update:c.update,drop:c.drop,execute:c.execute,promote:c.promote}},gce=({children:e})=>O.jsx("div",{className:"h-full w-full",children:O.jsx("div",{className:"flex h-full w-full flex-1 items-center justify-center",children:O.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-4 py-4 text-inactive-text",children:[O.jsx(on,{className:"absolute -right-full h-10 w-10 translate-x-1"}),O.jsx("div",{className:"text-center text-sm",children:e})]})})}),mce=e=>{switch(e){case"dataclass":return O.jsx(Pu,{className:"h-6 w-6"});case"singleton":return O.jsx(fj,{className:"h-6 w-6"});case"datastore":return O.jsx(lj,{className:"h-6 w-6"});case"attribute":return O.jsx(hj,{className:"h-6 w-6"});case"method":return O.jsx(tj,{className:"h-6 w-6"});case"singletonMethod":return O.jsx(sj,{className:"h-6 w-6"});case"entityselMethod":return O.jsx(aj,{className:"h-6 w-6"});case"entityMethod":return O.jsx(oj,{className:"h-6 w-6"});case"dsMethod":return O.jsx(ij,{className:"h-6 w-6"});case"dataclassMethod":return O.jsx(nj,{className:"h-6 w-6"});default:return O.jsx(Pu,{className:"h-6 w-6"})}},UD=({privileges:e,permission:t,hasChild:r,depth:n,isChild:i=!1,className:o,inSearch:a,toggleCollapse:s,collapsed:c,isRestrictedByDefault:d,toastMessageCallback:u,computedInherited:h})=>{const[p,v]=t.applyTo.split("."),y=C.useMemo(()=>h||fd(t,e.otherPrivs,e.rolePrivs,d),[h,e,t,d]);return O.jsxs("tr",{className:an("group even:bg-white/5 hover:bg-input-bg",o),children:[O.jsxs("td",{className:an("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((m,g)=>O.jsx("div",{className:an("ml-1.5 mr-1 w-[2px] bg-muted",{"mr-0.5":i})},g)),O.jsxs("div",{className:"flex items-center gap-3 py-2",children:[r&&O.jsx("button",{onClick:s,className:"w-3",children:c?O.jsx(uj,{className:"inline h-4 w-4"}):O.jsx(rj,{className:"inline h-4 w-4"})}),mce(t.type),a?t.applyTo:v||p]})]}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[pe.EPermissionType.ATTRIBUTE,pe.EPermissionType.DATASTORE,pe.EPermissionType.DATACLASS].includes(t.type)&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.read.value||y.read.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.read.value&&y.read.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.read.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.read.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[pe.EPermissionType.ATTRIBUTE,pe.EPermissionType.DATASTORE,pe.EPermissionType.DATACLASS].includes(t.type)&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.create.value||y.create.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.create.value&&y.create.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.read.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.read.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[pe.EPermissionType.ATTRIBUTE,pe.EPermissionType.DATASTORE,pe.EPermissionType.DATACLASS].includes(t.type)&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.update.value||y.update.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.update.value&&y.update.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.update.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.update.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})}),O.jsx("td",{className:"py-2 text-center group-hover:bg-input-bg",children:[pe.EPermissionType.ATTRIBUTE,pe.EPermissionType.DATASTORE,pe.EPermissionType.DATACLASS].includes(t.type)&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.drop.value||y.drop.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.drop.value&&y.drop.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.drop.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.drop.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})}),O.jsx("td",{className:"py-2 text-center group-hover:rounded-r group-hover:bg-input-bg",children:t.type!=="attribute"&&O.jsxs("div",{className:"relative mx-auto flex w-fit items-center justify-center gap-x-1",onClick:u,children:[O.jsx(ir,{value:y.execute.value||y.execute.inherited,isDisabled:!0}),O.jsx("div",{className:"absolute left-full top-1/2 flex -translate-y-1/2 translate-x-1/2 cursor-pointer items-center",children:!y.execute.value&&y.execute.inherited?O.jsx(Lr,{container:Br(),delay:100,label:O.jsx("div",{className:"space-y-1 p-1",children:y.execute.from.length?O.jsxs("div",{className:"flex items-start",children:[O.jsx(wi,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0"}),O.jsxs("p",{className:"flex flex-col gap-y-2",children:[O.jsx("span",{className:"mr-1",children:"Permission inherited from:"}),O.jsx("ul",{children:y.execute.from.map((m,g)=>O.jsx("li",{className:"cursor-pointer list-disc font-bold",children:m},g))})]})]}):null}),children:O.jsx(on,{className:"h-4 w-4"})}):""})]})})]})};function GD(e,t,r){const n=[],i=(a,s,c)=>n.push({id:a,permission:s,depth:c,hasChild:!1,isChild:!1}),o=(a,s,c,d,u,h)=>{n.push({id:a,permission:s,depth:c,hasChild:!0,isChild:d,toggleId:a,isCollapsed:u}),u||h()};for(const a of Object.values(e)){o("ds-group",{applyTo:a.applyTo,type:a.type},0,!1,t,()=>{for(const s of a.methods)i(`dsm-${s.applyTo}`,s,1);for(const s of a.dataClasses){const c=`dc-${s.applyTo}`;o(c,{applyTo:s.applyTo,type:s.type},1,!0,r[c]??!1,()=>{for(const d of s.attributes)i(`dca-${d.applyTo}`,d,2);for(const d of s.methods)i(`dcm-${d.applyTo}`,d,2)})}});for(const s of a.singletons){const c=`sing-${s.applyTo}`;o(c,{applyTo:s.applyTo,type:s.type},0,!0,r[c]??!1,()=>{for(const d of s.attributes)i(`singa-${d.applyTo}`,d,1);for(const d of s.methods)i(`singm-${d.applyTo}`,d,1)})}}return n}const KD=["datastore","singleton","dataclass","attribute","dsMethod","dataclassMethod","entityMethod","entityselMethod","singletonMethod"],yo={datastore:["datastore"],dataclass:["dataclass"],singleton:["singleton"],functions:["method","singletonMethod","dsMethod","dataclassMethod","entityMethod","entityselMethod"],attribute:["attribute"]},YD=Object.values(yo).flat();function pa(e,t){return t.length>0&&t.every(r=>e.includes(r))}function bce(e,t){return Array.from(new Set([...e,...t]))}function yce(e,t){return e.filter(r=>!t.includes(r))}const xce=({selectedRole:e})=>{const[t,r]=C.useState(null),[n,i]=C.useState(null),{styles:o,attributes:a}=Cd(t,n,{modifiers:[{name:"offset",options:{offset:[0,10]}}]}),s=Tr(),c=s.getRestrictedByDefault(),d=s.getPrivileges(),[u,h]=C.useState([]),[p,v]=C.useState([]),[y,m]=C.useState(""),[g,w]=C.useState("");C.useEffect(()=>{const J=setTimeout(()=>v(u),0);return()=>clearTimeout(J)},[u]);const x=s.getCatalogMethods(),_=s.getDataclasses(),S=s.getSingletons(),E=C.useMemo(()=>sae(x,Object.values(_),Object.values(S)),[x,_,S]),I=C.useMemo(()=>!p.length&&!g?[]:[...US(g,x,Object.values(_),Object.values(S))].filter(J=>p.length?p.includes(J.type):!0).sort((J,ae)=>{const he=KD.indexOf(J.type),ue=KD.indexOf(ae.type);return he!==ue?he-ue:J.applyTo.toLowerCase()>ae.applyTo.toLowerCase()?1:-1}),[g,p,x,_,S]),N=J=>h([...J]),T=J=>{h(ae=>pa(ae,J)?yce(ae,J):bce(ae,J))},M=J=>T(yo[J]),z=YD.every(J=>u.includes(J)),j=u.length>0&&!z,W=pa(u,yo.functions),U=()=>N(YD),A=()=>N([]),K=s.getRoles(),[V,te]=C.useState(K);C.useEffect(()=>{const J=setTimeout(()=>te(K),0);return()=>clearTimeout(J)},[K]);const G=C.useRef(null);C.useEffect(()=>{var J,ae;(ae=(J=G.current)==null?void 0:J.getScrollElement())==null||ae.scrollTo({top:0})},[e]);const re=cd({count:I.length,getScrollElement:()=>{var J;return((J=G.current)==null?void 0:J.getScrollElement())??null},estimateSize:()=>36,overscan:5,paddingEnd:40}),P=C.useMemo(()=>{const J=Object.values(d).find(le=>le.privilege==="guest"),ae=V[e],he=ae?Object.fromEntries(ae.privileges.map(le=>[le,d[le]]).filter(([,le])=>!!le)):{};if(c)return{rolePrivs:he,otherPrivs:J?{[J.id]:J}:{}};const ue=J?{[J.id]:{...J,active:!0}}:{},de=Object.fromEntries(Object.entries(d).filter(([le])=>le!==(J==null?void 0:J.id)&&!(ae!=null&&ae.privileges.includes(le))).map(([le,xe])=>[le,{...xe,active:!1}]));return{rolePrivs:he,otherPrivs:{...ue,...de}}},[d,V,e,c]),[B,X]=C.useState(!1),[Q,D]=C.useState({}),$=C.useMemo(()=>{const J=[];for(const ae of Object.values(E)){for(const he of ae.dataClasses)J.push(`dc-${he.applyTo}`);for(const he of ae.singletons)J.push(`sing-${he.applyTo}`)}return J},[E]),H=$.length>0&&$.every(J=>Q[J]===!0),q=C.useCallback(()=>{const J={};for(const ae of $)J[ae]=!0;D(J)},[$]),Y=C.useCallback(J=>{J==="ds-group"?X(ae=>!ae):D(ae=>({...ae,[J]:!ae[J]}))},[]),ie=C.useMemo(()=>{const J=new Map;for(const{permission:ae}of GD(E,!1,{}))J.set(`${ae.applyTo}|${ae.type}`,fd(ae,P.otherPrivs,P.rolePrivs,c));return J},[P,c,E]),ne=C.useMemo(()=>GD(E,B,Q),[E,B,Q]),ve=cd({count:ne.length,getScrollElement:()=>{var J;return((J=G.current)==null?void 0:J.getScrollElement())??null},estimateSize:()=>36,overscan:8,paddingEnd:15}),Z=C.useCallback(()=>{pe.toastSubject.next({kind:"info",markdown:!0,message:"**Info:** You can add or modify permissions only in the Privilege section.",customIcon:Ew})},[]);return O.jsxs(hf,{ref:G,className:"z-20 h-full flex-1 overflow-auto p-3.75 pt-0",style:{maxHeight:"calc(100vh - 5.5rem - 85px - 20px)"},children:[O.jsxs("table",{className:"relative h-full w-full border-collapse",children:[O.jsx("thead",{className:"sticky top-0 z-20 bg-panel-1",children:O.jsxs("tr",{className:"border-b border-grey-100",children:[O.jsx("td",{className:"py-2",children:O.jsxs("div",{className:"flex items-center gap-x-2",children:[O.jsx(Lr,{label:"Collapse All",position:"up",container:Br(),children:O.jsx(Jt,{color:"white",variant:"ghost",disabled:B&&H,onClick:()=>{H?(q(),X(!0)):q()},children:O.jsx(yV,{})})}),O.jsx(wt.Root,{className:"w-56",children:O.jsxs(wt.Group,{children:[O.jsx(wt.Icon,{children:O.jsx(dj,{})}),O.jsx(wt.Field,{type:"text",placeholder:"Search",value:y,onChange:J=>{const ae=J.target.value;m(ae),setTimeout(()=>w(ae),0)}}),O.jsx(wn.Popover,{className:"flex items-center",children:({open:J})=>O.jsxs(O.Fragment,{children:[O.jsx(wn.Popover.Button,{ref:r,children:O.jsx(wt.Icon,{isAction:!0,children:O.jsx(JD,{})})}),J&&O.jsx(ef,{children:O.jsx(wn.Popover.Panel,{ref:i,style:o.popper,...a.popper,className:"z-50",static:!0,children:O.jsxs(br,{depth:3,borderType:"light",className:"rounded-md border px-4 py-2.5 text-xs",children:[O.jsxs("label",{className:"mb-2 flex cursor-pointer items-center gap-2",children:[O.jsx(ir,{size:"sm",value:j?null:z,onChange:()=>z?A():U()}),O.jsx("h5",{className:"text-sm font-semibold",children:"Filter"})]}),O.jsxs("div",{className:"space-y-2 text-s",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:pa(u,yo.datastore),onChange:()=>M("datastore"),label:"Datastore"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:pa(u,yo.dataclass),onChange:()=>M("dataclass"),label:"Dataclass"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:pa(u,yo.singleton),onChange:()=>M("singleton"),label:"Singleton"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:W,onChange:()=>M("functions"),label:"Functions"})}),O.jsx("div",{className:"flex items-center",children:O.jsx(ir,{size:"sm",value:pa(u,yo.attribute),onChange:()=>M("attribute"),label:"Attribute"})})]})]})})})]})})]})})]})}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"read"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Create"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Update"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Delete"}),O.jsx("td",{className:"px-4 py-2 text-center text-[12px]",children:"Execute"})]})}),O.jsx("tbody",{className:"relative",children:p.length||g?O.jsxs(O.Fragment,{children:[re.getVirtualItems().length>0?O.jsx("tr",{style:{height:`${re.getVirtualItems()[0].start}px`},children:O.jsx("td",{colSpan:6})}):null,re.getVirtualItems().map(J=>{const ae=I[J.index];return O.jsx(UD,{privileges:P,permission:ae,depth:0,inSearch:!0,isRestrictedByDefault:c,allPrivileges:d,toastMessageCallback:Z,computedInherited:ie.get(`${ae.applyTo}|${ae.type}`)},`${ae.type}-${J.index}`)}),(()=>{const J=re.getVirtualItems();if(!J.length)return null;const ae=re.getTotalSize()-J[J.length-1].end;return ae>0?O.jsx("tr",{style:{height:`${ae}px`},children:O.jsx("td",{colSpan:6})}):null})()]}):O.jsxs(O.Fragment,{children:[ve.getVirtualItems().length>0?O.jsx("tr",{style:{height:`${ve.getVirtualItems()[0].start}px`},children:O.jsx("td",{colSpan:6})}):null,ve.getVirtualItems().map(J=>{const ae=ne[J.index];return O.jsx(UD,{privileges:P,permission:ae.permission,depth:ae.depth,hasChild:ae.hasChild,isChild:ae.isChild,collapsed:ae.isCollapsed,toggleCollapse:ae.toggleId?()=>Y(ae.toggleId):void 0,isRestrictedByDefault:c,allPrivileges:d,toastMessageCallback:Z,computedInherited:ie.get(`${ae.permission.applyTo}|${ae.permission.type}`)},ae.id)}),(()=>{const J=ve.getVirtualItems();if(!J.length)return null;const ae=ve.getTotalSize()-J[J.length-1].end;return ae>0?O.jsx("tr",{style:{height:`${ae}px`},children:O.jsx("td",{colSpan:6})}):null})()]})})]}),(g||p.length)&&!I.length?O.jsx(gce,{children:"The Permission you're looking for can't be found "}):null]})},wce=()=>O.jsx("div",{className:"flex flex-1 items-center justify-center",children:O.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-grey-200 border-t-primary-dark"})}),Sce=()=>{const e=Tr(),t=e.getRoles(),[r,n]=C.useState(null),[i,o]=C.useState(null),[a,s]=C.useState(""),[c,d]=C.useState(null),{styles:u,attributes:h}=Cd(r,i,{modifiers:[{name:"offset",options:{offset:[-10,10]}}],placement:"right-start"});C.useEffect(()=>{s(""),d(null)},[i]);const p=()=>{if(!a)throw new Error("Please enter a valid name");if(Object.values(t).find(g=>g.role.toLowerCase()===a.toLowerCase()))throw new Error(`A role with the name ${a} already exists`);const y=yz.generate(),m=pe.createRole(y,a,t);e.actions.updateRoles(m)};return O.jsx(wn.Popover,{children:({open:v,close:y})=>{const m=()=>{d(null);try{pe.validateName(a),p(),y()}catch(g){d(g.message)}};return O.jsxs(O.Fragment,{children:[O.jsx(wn.Popover.Button,{className:"rounded","data-cy":"New-priv-btn",as:"div",ref:n,children:O.jsx(Jt,{variant:"ghost",color:"white",children:O.jsx(ja,{className:"h-4 w-4"})})}),v&&O.jsx(ef,{children:O.jsx(wn.Popover.Panel,{ref:o,style:u.popper,...h.popper,"data-cy":"New-priv-pop-up",className:"z-50",static:!0,children:O.jsxs(br,{className:"min-w-[256px] border rounded px-4 py-2 text-xs shadow-md",depth:3,borderType:"light",children:[O.jsx("h5",{className:"mb-2 text-xs font-semibold",children:"Create New Role"}),O.jsx("div",{className:"mt-2",children:O.jsxs("label",{className:"flex items-center gap-x-4",children:[O.jsx("span",{children:"Name"}),O.jsx(wt.Root,{color:c?"negative":"primary",className:"w-full",children:O.jsxs(wt.Group,{children:[c&&O.jsx(wt.Message,{children:c}),O.jsx(wt.Field,{autoFocus:!0,value:a,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m()},type:"text"})]})})]})}),O.jsxs("div",{className:"mt-4 flex items-center justify-center gap-x-2",children:[O.jsx(Jt,{onClick:()=>{m()},children:"Create"}),O.jsx(Jt,{color:"white",variant:"outline",onClick:()=>y(),children:"Cancel"})]})]})})})]})}})},Ece=()=>{const e=Tr(),t=e.getRoles(),r=e.getPrivileges(),{selectedRole:n,deferredSelectedRole:i}=cS(),o=C.useMemo(()=>Object.values(t).sort((a,s)=>pe.localeCompare(a.role,s.role)),[t]);return O.jsxs("div",{className:"flex flex-1 h-full",children:[O.jsxs(br,{depth:1,className:"flex h-full w-89 flex-col border-r",children:[O.jsxs("div",{className:"flex shrink-0 items-center justify-between px-3.5 py-2.5",children:[O.jsxs("div",{className:"flex items-center gap-x-1",children:[O.jsx("span",{children:O.jsx(pd,{className:"h-3.5 w-3.5"})}),O.jsx("span",{className:"text-[11px] font-semibold",children:"Roles"})]}),O.jsx(Sce,{})]}),O.jsx("div",{className:"flex-1 overflow-auto p-4 pb-10 pt-1",children:o.length>0?O.jsx("div",{className:"flex flex-col gap-4",children:o.map(a=>O.jsx(pce,{role:a,privileges:r},a.id))}):O.jsx("div",{className:"flex h-full items-center justify-center",children:O.jsx("div",{className:"flex flex-1 items-center justify-center text-inactive-text",children:O.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-4",children:[O.jsx(on,{className:"h-10 w-10"}),O.jsx("div",{className:"font-semibold",children:"There are no roles"}),O.jsxs("div",{className:"flex items-center text-sm",children:["Create a new role by clicking on the"," ",O.jsx(ja,{className:"ml-2 inline h-4 w-4"})]})]})})})})]}),O.jsx(br,{depth:1,className:an("relative flex h-full w-full flex-1 flex-col items-stretch overflow-x-auto",{"border-l-[0.5px]":n}),children:O.jsx("div",{className:"flex h-full w-full select-none flex-col",children:n?O.jsxs(O.Fragment,{children:[O.jsx(vce,{}),i?O.jsx(xce,{selectedRole:i}):O.jsx(wce,{})]}):O.jsx(U4,{tab:"Role"})})})]})},mL=()=>{const e=Tr(),t=e.getQodly(),r=e.getSelectedTab(),n=e.getForceLogin(),i=e.getRestrictedByDefault(),{canUndo:o,canRedo:a}=e.getHistory(),s=C.useRef();return O.jsx("div",{className:"absolute inset-0 flex flex-1 overflow-hidden",children:O.jsx("div",{className:"relative flex flex-1 overflow-hidden","data-cy":"Roles&Privileges-editor-cy",ref:c=>s.current=c,children:O.jsxs("div",{className:"flex min-h-0 w-full flex-1 flex-col",children:[O.jsx($Y,{activeTab:r,forceLogin:n,restrictedByDefault:i,canUndo:o,canRedo:a,onUndo:e.actions.undo,onRedo:e.actions.redo,onTabChange:c=>{e.actions.toggleTab(c)},onForceLoginChange:c=>{e.actions.toggleForceLogin(c)},onRestrictedByDefaultChange:c=>{e.actions.toggleRestrictedByDefault(c)},qodly:t}),O.jsx("div",{className:r==="roles"?"flex flex-1 overflow-hidden":"hidden",children:O.jsx(VY,{children:O.jsx(Ece,{})})}),O.jsx("div",{className:r==="privileges"?"flex flex-1 overflow-hidden":"hidden",children:O.jsx(fce,{})})]})})})},_ce="object",Oce={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"}}}}},Cce={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"]},PermissionEntry:{type:"array",items:{type:"string"}},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:{$ref:"#/definitions/PermissionEntry"},create:{$ref:"#/definitions/PermissionEntry"},update:{$ref:"#/definitions/PermissionEntry"},drop:{$ref:"#/definitions/PermissionEntry"},execute:{$ref:"#/definitions/PermissionEntry"},promote:{$ref:"#/definitions/PermissionEntry"}},required:["applyTo","type"]}},Ice={type:_ce,properties:Oce,definitions:Cce},Rce=()=>{const{modals:e,closeModal:t,editModal:r}=Kae();return O.jsx(O.Fragment,{children:e.map((n,i)=>O.jsx(pe.Modal,{hasOverlay:i===0,...n,onClose:t,onEdit:r,container:Br()},n.id))})},bL=e=>{if(!e)return pe.rolesToAPI(pe.sanitizeRoles({}));try{return pe.rolesToAPI(pe.sanitizeRoles(JSON.parse(e)))}catch{return pe.rolesToAPI(pe.sanitizeRoles({}))}},Nce=({initialValue:e,onChange:t,...r})=>{const n=Tr(),i=n.getRolesFlags(),o=n.getRolesAndPrivileges(),a=C.useMemo(()=>bL(e),[e]),s=C.useRef(o),c=C.useRef(a),d=C.useRef(a);return C.useEffect(()=>{s.current=o},[o]),C.useEffect(()=>{Xi.isEqual(a,d.current)||(d.current=a,c.current=a,!Xi.isEqual(a,s.current)&&n.actions.setRolesContent({content:a,flags:{touched:!1}}))},[n,a]),pe.useDidMountEffect(()=>{if(!(!t||!i.touched)&&!Xi.isEqual(o,c.current))try{const u=JSON.stringify(o,null,2);t(u),c.current=o}catch(u){console.error("[Roles Editor Standalone] Error on value stringify:",u)}},[o,i.touched,t]),O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"relative h-screen z-10 overflow-hidden",children:O.jsx(mL,{...r})}),O.jsx(Rce,{})]})},Tce=e=>{const t=Gae();return O.jsx(dz,{adapter:t,children:O.jsx(pe.TipsProvider,{children:O.jsx(Nce,{...e})})})},Pce=({initialValue:e,catalog:t,history:r,activeTab:n,onTabChange:i,...o})=>{const a=C.useMemo(()=>({...pe.sanitizeRoles(bL(e)),flags:{touched:!1}}),[e]);return O.jsx(Uae,{initialState:a,catalog:t,history:r,selectedTab:n,onTabChange:i,children:O.jsx(Tce,{initialValue:e,...o})})};exports.ROLES_EDITOR_SCOPE_CLASS=XD.ROLES_EDITOR_SCOPE_CLASS;exports.EditorStateAdapterProvider=dz;exports.Roles=mL;exports.Standalone=Pce;exports.jsonSchema=Ice;exports.useReduxAdapter=fae;
|
|
120
120
|
//# sourceMappingURL=index.cjs.js.map
|