@veltdev/sdk-staging 6.0.38 → 6.0.40

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.
Files changed (60) hide show
  1. package/app/models/data/core-events.data.model.d.ts +14 -0
  2. package/{chunk-UM4DCTY2.js → chunk-36PXOB25.js} +1 -1
  3. package/{chunk-PHUEJCYV.js → chunk-37SHBMMS.js} +1 -1
  4. package/{chunk-3WXPNBX5.js → chunk-3COV4GP2.js} +1 -1
  5. package/{chunk-UW6RLILR.js → chunk-3WMZHIUK.js} +1 -1
  6. package/{chunk-2BTM4CFE.js → chunk-47QXEGDS.js} +1 -1
  7. package/{chunk-LYWPFYXA.js → chunk-4YENHG6U.js} +1 -1
  8. package/{chunk-RNFB3ETM.js → chunk-4Z5OANZ2.js} +1 -1
  9. package/{chunk-KXR5HWPR.js → chunk-5EAG5HB7.js} +1 -1
  10. package/{chunk-CGUTLGPR.js → chunk-5HJEEWJD.js} +1 -1
  11. package/{chunk-X7MTAUNM.js → chunk-5YPWPEJV.js} +1 -1
  12. package/{chunk-6GGZZ4AU.js → chunk-6IBFYOW4.js} +1 -1
  13. package/{chunk-5VC7CCBD.js → chunk-A62TJPHK.js} +1 -1
  14. package/{chunk-WHDXUE5R.js → chunk-BK3ANW44.js} +1 -1
  15. package/{chunk-FABIYF77.js → chunk-CM4DXJHV.js} +1 -1
  16. package/{chunk-J63WRUBY.js → chunk-EJIVVAFM.js} +1 -1
  17. package/{chunk-MYDCS2BE.js → chunk-EKQVWLGI.js} +1 -1
  18. package/{chunk-5VEPPJ7L.js → chunk-FE4IXZWI.js} +1 -1
  19. package/{chunk-OPZBNZVO.js → chunk-GP4ZSCRM.js} +1 -1
  20. package/{chunk-2QEJSDDK.js → chunk-GXKW7UHJ.js} +1 -1
  21. package/{chunk-LURMWRN2.js → chunk-I5NR2DMB.js} +1 -1
  22. package/{chunk-7GOPVFGG.js → chunk-K4WKCMNB.js} +1 -1
  23. package/{chunk-CRZUWE4H.js → chunk-LRZZ4NK5.js} +1 -1
  24. package/{chunk-3C3NVOFE.js → chunk-LVHGTHGQ.js} +1 -1
  25. package/{chunk-A67RL2PN.js → chunk-O3G53MZM.js} +1 -1
  26. package/{chunk-EUGFBHET.js → chunk-OZOKT55V.js} +1 -1
  27. package/{chunk-3INUN5X4.js → chunk-QTFSIBJ4.js} +1 -1
  28. package/{chunk-MU4JCWH6.js → chunk-SIENIDJ3.js} +1 -1
  29. package/{chunk-5YQBTUDX.js → chunk-TGIEWAFN.js} +1 -1
  30. package/{chunk-FQKWEEFD.js → chunk-U2R42GHO.js} +1 -1
  31. package/{chunk-QTMY2244.js → chunk-UGXNNWVG.js} +1 -1
  32. package/chunk-UQB52CCU.js +174 -0
  33. package/{chunk-BGHA3HPN.js → chunk-VLZ4EKGU.js} +1 -1
  34. package/{chunk-KDR7F33G.js → chunk-XKPPKXHG.js} +1 -1
  35. package/{chunk-VHPIMIJS.js → chunk-YDELC3DR.js} +1 -1
  36. package/{chunk-KSHKS6KZ.js → chunk-YJ4WTX4K.js} +1 -1
  37. package/{chunk-XCL6Y7ID.js → chunk-ZG4PAYOL.js} +1 -1
  38. package/package.json +1 -1
  39. package/velt-activity-log.js +1 -1
  40. package/velt-area.js +1 -1
  41. package/velt-arrow.js +1 -1
  42. package/velt-comment.js +8 -8
  43. package/velt-crdt.js +1 -1
  44. package/velt-cursor.js +1 -1
  45. package/velt-huddle.js +1 -1
  46. package/velt-live-state-sync.js +1 -1
  47. package/velt-notification.js +1 -1
  48. package/velt-portable.js +1 -1
  49. package/velt-presence.js +1 -1
  50. package/velt-reaction.js +1 -1
  51. package/velt-recorder.js +1 -1
  52. package/velt-rewriter.js +1 -1
  53. package/velt-selection.js +1 -1
  54. package/velt-tag.js +1 -1
  55. package/velt-user-invite.js +1 -1
  56. package/velt-user-request.js +1 -1
  57. package/velt-video-player.js +1 -1
  58. package/velt-views.js +1 -1
  59. package/velt.js +2 -2
  60. package/chunk-XUBWZTRK.js +0 -174
@@ -1,4 +1,4 @@
1
- import{D as ro,E as Bt,p as oo}from"./chunk-UM4DCTY2.js";import{$a as kn,$c as Lt,$e as Yn,Aa as An,Ac as $n,Ba as Rt,Bc as q,Bj as Se,Bk as zt,Cb as Un,Cj as je,D as Et,Db as Nn,Dc as Mt,Dj as Ie,E,Ee as D,Ej as at,F as Ot,Fb as Tt,Fc as Vn,G as wt,Gb as xt,Gj as x,Ha as Rn,Hb as Pt,He as re,Ia as B,Ii as Ut,J as At,Ja as U,Jj as to,K as te,Ka as ne,Lb as zn,M as X,Mb as nt,Mf as Xn,Na as be,O as yn,Oj as bi,Pa as oe,Qa as Fe,Qf as yi,R as Cn,Ra as Y,S as bn,Sg as qn,Ta as Ue,U as Ce,Ua as mi,Ud as jn,V as v,Vd as Hn,W as de,Wa as G,X as Sn,Xa as N,Y as Q,Ya as L,_ as In,_a as W,_c as H,_e as Wn,_f as w,_i as st,a as m,aa as Dn,ab as kt,ac as ze,ai as Ci,b as k,ba as b,ca as F,da as A,db as Ne,dg as Zn,di as rt,dk as Si,ea as T,ee as Gn,fa as h,fb as ue,fi as Jn,g as z,gk as io,h as K,ha as Me,i as ye,j as mn,k as y,l as I,n as _n,na as O,o as vn,oa as M,ob as Tn,oj as Nt,pa as En,pb as xn,pj as eo,q as St,qj as J,r as _,ra as Le,rb as Pn,re as ot,rf as Kn,rj as Ve,s as It,sa as j,sb as Mn,tb as Ln,tc as Bn,ua as On,uc as vi,v as S,va as wn,vc as Be,vg as Qn,w as it,wa as ie,wk as no,x as Dt,xa as he,xe as Ft,ya as R,yb as _i,za as gi,zb as Fn,zc as $e}from"./chunk-XUBWZTRK.js";function se(n,i=0){return so(n)?Number(n):arguments.length===2?i:0}function so(n){return!isNaN(parseFloat(n))&&!isNaN(Number(n))}function De(n){return n instanceof R?n.nativeElement:n}var br=new A("cdk-dir-doc",{providedIn:"root",factory:Sr});function Sr(){return h(M)}var Ir=/^(ar|ckb|dv|he|iw|fa|nqo|ps|sd|ug|ur|yi|.*[-_](Adlm|Arab|Hebr|Nkoo|Rohg|Thaa))(?!.*[-_](Latn|Cyrl)($|-|_))($|-|_)/i;function ao(n){let i=n?.toLowerCase()||"";return i==="auto"&&typeof navigator<"u"&&navigator?.language?Ir.test(navigator.language)?"rtl":"ltr":i==="rtl"?"rtl":"ltr"}var ae=(()=>{class n{get value(){return this.valueSignal()}valueSignal=j("ltr");change=new B;constructor(){let e=h(br,{optional:!0});if(e){let t=e.body?e.body.dir:null,o=e.documentElement?e.documentElement.dir:null;this.valueSignal.set(ao(t||o||"ltr"))}}ngOnDestroy(){this.change.complete()}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();var Z=(function(n){return n[n.NORMAL=0]="NORMAL",n[n.NEGATED=1]="NEGATED",n[n.INVERTED=2]="INVERTED",n})(Z||{}),$t,Ee;function Vt(){if(Ee==null){if(typeof document!="object"||!document||typeof Element!="function"||!Element)return Ee=!1,Ee;if(document.documentElement?.style&&"scrollBehavior"in document.documentElement.style)Ee=!0;else{let n=Element.prototype.scrollTo;n?Ee=!/\{\s*\[native code\]\s*\}/.test(n.toString()):Ee=!1}}return Ee}function He(){if(typeof document!="object"||!document)return Z.NORMAL;if($t==null){let n=document.createElement("div"),i=n.style;n.dir="rtl",i.width="1px",i.overflow="auto",i.visibility="hidden",i.pointerEvents="none",i.position="absolute";let e=document.createElement("div"),t=e.style;t.width="2px",t.height="1px",n.appendChild(e),document.body.appendChild(n),$t=Z.NORMAL,n.scrollLeft===0&&(n.scrollLeft=1,$t=n.scrollLeft===0?Z.NEGATED:Z.INVERTED),n.remove()}return $t}var fe=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=N({type:n});static \u0275inj=F({})}return n})();var jt=class{};function co(n){return n&&typeof n.connect=="function"&&!(n instanceof mn)}var Ht=class extends jt{_data;constructor(i){super(),this._data=i}connect(){return It(this._data)?this._data:_(this._data)}disconnect(){}},ct=(function(n){return n[n.REPLACED=0]="REPLACED",n[n.INSERTED=1]="INSERTED",n[n.MOVED=2]="MOVED",n[n.REMOVED=3]="REMOVED",n})(ct||{}),Ii=new A("_ViewRepeater"),Gt=class{viewCacheSize=20;_viewCache=[];applyChanges(i,e,t,o,r){i.forEachOperation((s,a,c)=>{let l,d;if(s.previousIndex==null){let u=()=>t(s,a,c);l=this._insertView(u,c,e,o(s)),d=l?ct.INSERTED:ct.REPLACED}else c==null?(this._detachAndCacheView(a,e),d=ct.REMOVED):(l=this._moveView(a,c,e,o(s)),d=ct.MOVED);r&&r({context:l?.context,operation:d,record:s})})}detach(){for(let i of this._viewCache)i.destroy();this._viewCache=[]}_insertView(i,e,t,o){let r=this._insertViewFromCache(e,t);if(r){r.context.$implicit=o;return}let s=i();return t.createEmbeddedView(s.templateRef,s.context,s.index)}_detachAndCacheView(i,e){let t=e.detach(i);this._maybeCacheView(t,e)}_moveView(i,e,t,o){let r=t.get(i);return t.move(r,e),r.context.$implicit=o,r}_maybeCacheView(i,e){if(this._viewCache.length<this.viewCacheSize)this._viewCache.push(i);else{let t=e.indexOf(i);t===-1?i.destroy():e.remove(t)}}_insertViewFromCache(i,e){let t=this._viewCache.pop();return t&&e.insert(t,i),t||null}};var Dr=["contentWrapper"],Er=["*"],uo=new A("VIRTUAL_SCROLL_STRATEGY"),Di=class{_scrolledIndexChange=new y;scrolledIndexChange=this._scrolledIndexChange.pipe(X());_viewport=null;_itemSize;_minBufferPx;_maxBufferPx;constructor(i,e,t){this._itemSize=i,this._minBufferPx=e,this._maxBufferPx=t}attach(i){this._viewport=i,this._updateTotalContentSize(),this._updateRenderedRange()}detach(){this._scrolledIndexChange.complete(),this._viewport=null}updateItemAndBufferSize(i,e,t){t<e,this._itemSize=i,this._minBufferPx=e,this._maxBufferPx=t,this._updateTotalContentSize(),this._updateRenderedRange()}onContentScrolled(){this._updateRenderedRange()}onDataLengthChanged(){this._updateTotalContentSize(),this._updateRenderedRange()}onContentRendered(){}onRenderedOffsetChanged(){}scrollToIndex(i,e){this._viewport&&this._viewport.scrollToOffset(i*this._itemSize,e)}_updateTotalContentSize(){this._viewport&&this._viewport.setTotalContentSize(this._viewport.getDataLength()*this._itemSize)}_updateRenderedRange(){if(!this._viewport)return;let i=this._viewport.getRenderedRange(),e={start:i.start,end:i.end},t=this._viewport.getViewportSize(),o=this._viewport.getDataLength(),r=this._viewport.measureScrollOffset(),s=this._itemSize>0?r/this._itemSize:0;if(e.end>o){let c=Math.ceil(t/this._itemSize),l=Math.max(0,Math.min(s,o-c));s!=l&&(s=l,r=l*this._itemSize,e.start=Math.floor(s)),e.end=Math.max(0,Math.min(o,e.start+c))}let a=r-e.start*this._itemSize;if(a<this._minBufferPx&&e.start!=0){let c=Math.ceil((this._maxBufferPx-a)/this._itemSize);e.start=Math.max(0,e.start-c),e.end=Math.min(o,Math.ceil(s+(t+this._minBufferPx)/this._itemSize))}else{let c=e.end*this._itemSize-(r+t);if(c<this._minBufferPx&&e.end!=o){let l=Math.ceil((this._maxBufferPx-c)/this._itemSize);l>0&&(e.end=Math.min(o,e.end+l),e.start=Math.max(0,Math.floor(s-this._minBufferPx/this._itemSize)))}}this._viewport.setRenderedRange(e),this._viewport.setRenderedContentOffset(Math.round(this._itemSize*e.start)),this._scrolledIndexChange.next(Math.floor(s))}};function Or(n){return n._scrollStrategy}var wr=(()=>{class n{get itemSize(){return this._itemSize}set itemSize(e){this._itemSize=se(e)}_itemSize=20;get minBufferPx(){return this._minBufferPx}set minBufferPx(e){this._minBufferPx=se(e)}_minBufferPx=100;get maxBufferPx(){return this._maxBufferPx}set maxBufferPx(e){this._maxBufferPx=se(e)}_maxBufferPx=200;_scrollStrategy=new Di(this.itemSize,this.minBufferPx,this.maxBufferPx);ngOnChanges(){this._scrollStrategy.updateItemAndBufferSize(this.itemSize,this.minBufferPx,this.maxBufferPx)}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,selectors:[["cdk-virtual-scroll-viewport","itemSize",""]],inputs:{itemSize:"itemSize",minBufferPx:"minBufferPx",maxBufferPx:"maxBufferPx"},features:[ze([{provide:uo,useFactory:Or,deps:[Dn(()=>n)]}]),ie]})}return n})(),Ar=20,lt=(()=>{class n{_ngZone=h(U);_platform=h(H);_renderer=h(oe).createRenderer(null,null);_cleanupGlobalListener;constructor(){}_scrolled=new y;_scrolledCount=0;scrollContainers=new Map;register(e){this.scrollContainers.has(e)||this.scrollContainers.set(e,e.elementScrolled().subscribe(()=>this._scrolled.next(e)))}deregister(e){let t=this.scrollContainers.get(e);t&&(t.unsubscribe(),this.scrollContainers.delete(e))}scrolled(e=Ar){return this._platform.isBrowser?new ye(t=>{this._cleanupGlobalListener||(this._cleanupGlobalListener=this._ngZone.runOutsideAngular(()=>this._renderer.listen("document","scroll",()=>this._scrolled.next())));let o=e>0?this._scrolled.pipe(Ot(e)).subscribe(t):this._scrolled.subscribe(t);return this._scrolledCount++,()=>{o.unsubscribe(),this._scrolledCount--,this._scrolledCount||(this._cleanupGlobalListener?.(),this._cleanupGlobalListener=void 0)}}):_()}ngOnDestroy(){this._cleanupGlobalListener?.(),this._cleanupGlobalListener=void 0,this.scrollContainers.forEach((e,t)=>this.deregister(t)),this._scrolled.complete()}ancestorScrolled(e,t){let o=this.getAncestorScrollContainers(e);return this.scrolled(t).pipe(E(r=>!r||o.indexOf(r)>-1))}getAncestorScrollContainers(e){let t=[];return this.scrollContainers.forEach((o,r)=>{this._scrollableContainsElement(r,e)&&t.push(r)}),t}_scrollableContainsElement(e,t){let o=De(t),r=e.getElementRef().nativeElement;do if(o==r)return!0;while(o=o.parentElement);return!1}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),dt=(()=>{class n{elementRef=h(R);scrollDispatcher=h(lt);ngZone=h(U);dir=h(ae,{optional:!0});_scrollElement=this.elementRef.nativeElement;_destroyed=new y;_renderer=h(Fe);_cleanupScroll;_elementScrolled=new y;constructor(){}ngOnInit(){this._cleanupScroll=this.ngZone.runOutsideAngular(()=>this._renderer.listen(this._scrollElement,"scroll",e=>this._elementScrolled.next(e))),this.scrollDispatcher.register(this)}ngOnDestroy(){this._cleanupScroll?.(),this._elementScrolled.complete(),this.scrollDispatcher.deregister(this),this._destroyed.next(),this._destroyed.complete()}elementScrolled(){return this._elementScrolled}getElementRef(){return this.elementRef}scrollTo(e){let t=this.elementRef.nativeElement,o=this.dir&&this.dir.value=="rtl";e.left==null&&(e.left=o?e.end:e.start),e.right==null&&(e.right=o?e.start:e.end),e.bottom!=null&&(e.top=t.scrollHeight-t.clientHeight-e.bottom),o&&He()!=Z.NORMAL?(e.left!=null&&(e.right=t.scrollWidth-t.clientWidth-e.left),He()==Z.INVERTED?e.left=e.right:He()==Z.NEGATED&&(e.left=e.right?-e.right:e.right)):e.right!=null&&(e.left=t.scrollWidth-t.clientWidth-e.right),this._applyScrollToOptions(e)}_applyScrollToOptions(e){let t=this.elementRef.nativeElement;Vt()?t.scrollTo(e):(e.top!=null&&(t.scrollTop=e.top),e.left!=null&&(t.scrollLeft=e.left))}measureScrollOffset(e){let t="left",o="right",r=this.elementRef.nativeElement;if(e=="top")return r.scrollTop;if(e=="bottom")return r.scrollHeight-r.clientHeight-r.scrollTop;let s=this.dir&&this.dir.value=="rtl";return e=="start"?e=s?o:t:e=="end"&&(e=s?t:o),s&&He()==Z.INVERTED?e==t?r.scrollWidth-r.clientWidth-r.scrollLeft:r.scrollLeft:s&&He()==Z.NEGATED?e==t?r.scrollLeft+r.scrollWidth-r.clientWidth:-r.scrollLeft:e==t?r.scrollLeft:r.scrollWidth-r.clientWidth-r.scrollLeft}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,selectors:[["","cdk-scrollable",""],["","cdkScrollable",""]]})}return n})(),Rr=20,Oe=(()=>{class n{_platform=h(H);_listeners;_viewportSize;_change=new y;_document=h(M);constructor(){let e=h(U),t=h(oe).createRenderer(null,null);e.runOutsideAngular(()=>{if(this._platform.isBrowser){let o=r=>this._change.next(r);this._listeners=[t.listen("window","resize",o),t.listen("window","orientationchange",o)]}this.change().subscribe(()=>this._viewportSize=null)})}ngOnDestroy(){this._listeners?.forEach(e=>e()),this._change.complete()}getViewportSize(){this._viewportSize||this._updateViewportSize();let e={width:this._viewportSize.width,height:this._viewportSize.height};return this._platform.isBrowser||(this._viewportSize=null),e}getViewportRect(){let e=this.getViewportScrollPosition(),{width:t,height:o}=this.getViewportSize();return{top:e.top,left:e.left,bottom:e.top+o,right:e.left+t,height:o,width:t}}getViewportScrollPosition(){if(!this._platform.isBrowser)return{top:0,left:0};let e=this._document,t=this._getWindow(),o=e.documentElement,r=o.getBoundingClientRect(),s=-r.top||e.body.scrollTop||t.scrollY||o.scrollTop||0,a=-r.left||e.body.scrollLeft||t.scrollX||o.scrollLeft||0;return{top:s,left:a}}change(e=Rr){return e>0?this._change.pipe(Ot(e)):this._change}_getWindow(){return this._document.defaultView||window}_updateViewportSize(){let e=this._getWindow();this._viewportSize=this._platform.isBrowser?{width:e.innerWidth,height:e.innerHeight}:{width:0,height:0}}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),lo=new A("VIRTUAL_SCROLLABLE"),kr=(()=>{class n extends dt{constructor(){super()}measureViewportSize(e){let t=this.elementRef.nativeElement;return e==="horizontal"?t.clientWidth:t.clientHeight}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,features:[W]})}return n})();function Tr(n,i){return n.start==i.start&&n.end==i.end}var xr=typeof requestAnimationFrame<"u"?vn:_n,fo=(()=>{class n extends kr{elementRef=h(R);_changeDetectorRef=h($e);_scrollStrategy=h(uo,{optional:!0});scrollable=h(lo,{optional:!0});_platform=h(H);_detachedSubject=new y;_renderedRangeSubject=new y;get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._orientation=e,this._calculateSpacerSize())}_orientation="vertical";appendOnly=!1;scrolledIndexChange=new ye(e=>this._scrollStrategy.scrolledIndexChange.subscribe(t=>Promise.resolve().then(()=>this.ngZone.run(()=>e.next(t)))));_contentWrapper;renderedRangeStream=this._renderedRangeSubject;_totalContentSize=0;_totalContentWidth=j("");_totalContentHeight=j("");_renderedContentTransform;_renderedRange={start:0,end:0};_dataLength=0;_viewportSize=0;_forOf;_renderedContentOffset=0;_renderedContentOffsetNeedsRewrite=!1;_changeDetectionNeeded=j(!1);_runAfterChangeDetection=[];_viewportChanges=K.EMPTY;_injector=h(O);_isDestroyed=!1;constructor(){super();let e=h(Oe);this._scrollStrategy,this._viewportChanges=e.change().subscribe(()=>{this.checkViewportSize()}),this.scrollable||(this.elementRef.nativeElement.classList.add("cdk-virtual-scrollable"),this.scrollable=this);let t=Be(()=>{this._changeDetectionNeeded()&&this._doChangeDetection()},{injector:h(Ne).injector});h(En).onDestroy(()=>{t.destroy()})}ngOnInit(){this._platform.isBrowser&&(this.scrollable===this&&super.ngOnInit(),this.ngZone.runOutsideAngular(()=>Promise.resolve().then(()=>{this._measureViewportSize(),this._scrollStrategy.attach(this),this.scrollable.elementScrolled().pipe(Ce(null),Ot(0,xr),de(this._destroyed)).subscribe(()=>this._scrollStrategy.onContentScrolled()),this._markChangeDetectionNeeded()})))}ngOnDestroy(){this.detach(),this._scrollStrategy.detach(),this._renderedRangeSubject.complete(),this._detachedSubject.complete(),this._viewportChanges.unsubscribe(),this._isDestroyed=!0,super.ngOnDestroy()}attach(e){this._forOf,this.ngZone.runOutsideAngular(()=>{this._forOf=e,this._forOf.dataStream.pipe(de(this._detachedSubject)).subscribe(t=>{let o=t.length;o!==this._dataLength&&(this._dataLength=o,this._scrollStrategy.onDataLengthChanged()),this._doChangeDetection()})})}detach(){this._forOf=null,this._detachedSubject.next()}getDataLength(){return this._dataLength}getViewportSize(){return this._viewportSize}getRenderedRange(){return this._renderedRange}measureBoundingClientRectWithScrollOffset(e){return this.getElementRef().nativeElement.getBoundingClientRect()[e]}setTotalContentSize(e){this._totalContentSize!==e&&(this._totalContentSize=e,this._calculateSpacerSize(),this._markChangeDetectionNeeded())}setRenderedRange(e){Tr(this._renderedRange,e)||(this.appendOnly&&(e={start:0,end:Math.max(this._renderedRange.end,e.end)}),this._renderedRangeSubject.next(this._renderedRange=e),this._markChangeDetectionNeeded(()=>this._scrollStrategy.onContentRendered()))}getOffsetToRenderedContentStart(){return this._renderedContentOffsetNeedsRewrite?null:this._renderedContentOffset}setRenderedContentOffset(e,t="to-start"){e=this.appendOnly&&t==="to-start"?0:e;let o=this.dir&&this.dir.value=="rtl",r=this.orientation=="horizontal",s=r?"X":"Y",c=`translate${s}(${Number((r&&o?-1:1)*e)}px)`;this._renderedContentOffset=e,t==="to-end"&&(c+=` translate${s}(-100%)`,this._renderedContentOffsetNeedsRewrite=!0),this._renderedContentTransform!=c&&(this._renderedContentTransform=c,this._markChangeDetectionNeeded(()=>{this._renderedContentOffsetNeedsRewrite?(this._renderedContentOffset-=this.measureRenderedContentSize(),this._renderedContentOffsetNeedsRewrite=!1,this.setRenderedContentOffset(this._renderedContentOffset)):this._scrollStrategy.onRenderedOffsetChanged()}))}scrollToOffset(e,t="auto"){let o={behavior:t};this.orientation==="horizontal"?o.start=e:o.top=e,this.scrollable.scrollTo(o)}scrollToIndex(e,t="auto"){this._scrollStrategy.scrollToIndex(e,t)}measureScrollOffset(e){let t;return this.scrollable==this?t=o=>super.measureScrollOffset(o):t=o=>this.scrollable.measureScrollOffset(o),Math.max(0,t(e??(this.orientation==="horizontal"?"start":"top"))-this.measureViewportOffset())}measureViewportOffset(e){let t,o="left",r="right",s=this.dir?.value=="rtl";e=="start"?t=s?r:o:e=="end"?t=s?o:r:e?t=e:t=this.orientation==="horizontal"?"left":"top";let a=this.scrollable.measureBoundingClientRectWithScrollOffset(t);return this.elementRef.nativeElement.getBoundingClientRect()[t]-a}measureRenderedContentSize(){let e=this._contentWrapper.nativeElement;return this.orientation==="horizontal"?e.offsetWidth:e.offsetHeight}measureRangeSize(e){return this._forOf?this._forOf.measureRangeSize(e,this.orientation):0}checkViewportSize(){this._measureViewportSize(),this._scrollStrategy.onDataLengthChanged()}_measureViewportSize(){this._viewportSize=this.scrollable.measureViewportSize(this.orientation)}_markChangeDetectionNeeded(e){e&&this._runAfterChangeDetection.push(e),!Bn(this._changeDetectionNeeded)&&this.ngZone.runOutsideAngular(()=>{Promise.resolve().then(()=>{this.ngZone.run(()=>{this._changeDetectionNeeded.set(!0)})})})}_doChangeDetection(){this._isDestroyed||this.ngZone.run(()=>{this._changeDetectorRef.markForCheck(),this._contentWrapper.nativeElement.style.transform=this._renderedContentTransform,ne(()=>{this._changeDetectionNeeded.set(!1);let e=this._runAfterChangeDetection;this._runAfterChangeDetection=[];for(let t of e)t()},{injector:this._injector})})}_calculateSpacerSize(){this._totalContentHeight.set(this.orientation==="horizontal"?"":`${this._totalContentSize}px`),this._totalContentWidth.set(this.orientation==="horizontal"?`${this._totalContentSize}px`:"")}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=G({type:n,selectors:[["cdk-virtual-scroll-viewport"]],viewQuery:function(t,o){if(t&1&&Tt(Dr,7),t&2){let r;xt(r=Pt())&&(o._contentWrapper=r.first)}},hostAttrs:[1,"cdk-virtual-scroll-viewport"],hostVars:4,hostBindings:function(t,o){t&2&&nt("cdk-virtual-scroll-orientation-horizontal",o.orientation==="horizontal")("cdk-virtual-scroll-orientation-vertical",o.orientation!=="horizontal")},inputs:{orientation:"orientation",appendOnly:[2,"appendOnly","appendOnly",q]},outputs:{scrolledIndexChange:"scrolledIndexChange"},features:[ze([{provide:dt,useFactory:(e,t)=>e||t,deps:[[new wn,new On(lo)],n]}]),W],ngContentSelectors:Er,decls:4,vars:4,consts:[["contentWrapper",""],[1,"cdk-virtual-scroll-content-wrapper"],[1,"cdk-virtual-scroll-spacer"]],template:function(t,o){t&1&&(Un(),Pn(0,"div",1,0),Nn(2),Mn(),Ln(3,"div",2)),t&2&&(Rn(3),zn("width",o._totalContentWidth())("height",o._totalContentHeight()))},styles:[`cdk-virtual-scroll-viewport{display:block;position:relative;transform:translateZ(0)}.cdk-virtual-scrollable{overflow:auto;will-change:scroll-position;contain:strict}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{height:1px;transform-origin:0 0;flex:0 0 auto}[dir=rtl] .cdk-virtual-scroll-spacer{transform-origin:100% 0}
1
+ import{D as ro,E as Bt,p as oo}from"./chunk-36PXOB25.js";import{$a as kn,$c as Lt,$e as Yn,Aa as An,Ac as $n,Ba as Rt,Bc as q,Cb as Un,D as Et,Db as Nn,Dc as Mt,Dk as no,E,Ee as D,F as Ot,Fb as Tt,Fc as Vn,G as wt,Gb as xt,Ha as Rn,Hb as Pt,He as re,Ia as B,Ii as Ut,Ij as Se,Ik as zt,J as At,Ja as U,Jj as je,K as te,Ka as ne,Kj as Ie,Lb as zn,Lj as at,M as X,Mb as nt,Mf as Xn,Na as be,Nj as x,O as yn,Pa as oe,Qa as Fe,Qf as yi,Qj as to,R as Cn,Ra as Y,S as bn,Sg as qn,Ta as Ue,U as Ce,Ua as mi,Ud as jn,V as v,Vd as Hn,Vj as bi,W as de,Wa as G,X as Sn,Xa as N,Y as Q,Ya as L,_ as In,_a as W,_c as H,_e as Wn,_f as w,_i as st,a as m,aa as Dn,ab as kt,ac as ze,ai as Ci,b as k,ba as b,ca as F,da as A,db as Ne,dg as Zn,di as rt,ea as T,ee as Gn,fa as h,fb as ue,fi as Jn,g as z,h as K,ha as Me,i as ye,j as mn,k as y,kk as Si,l as I,n as _n,na as O,nk as io,o as vn,oa as M,ob as Tn,oj as Nt,pa as En,pb as xn,pj as eo,q as St,qj as J,r as _,ra as Le,rb as Pn,re as ot,rf as Kn,rj as Ve,s as It,sa as j,sb as Mn,tb as Ln,tc as Bn,ua as On,uc as vi,v as S,va as wn,vc as Be,vg as Qn,w as it,wa as ie,x as Dt,xa as he,xe as Ft,ya as R,yb as _i,za as gi,zb as Fn,zc as $e}from"./chunk-UQB52CCU.js";function se(n,i=0){return so(n)?Number(n):arguments.length===2?i:0}function so(n){return!isNaN(parseFloat(n))&&!isNaN(Number(n))}function De(n){return n instanceof R?n.nativeElement:n}var br=new A("cdk-dir-doc",{providedIn:"root",factory:Sr});function Sr(){return h(M)}var Ir=/^(ar|ckb|dv|he|iw|fa|nqo|ps|sd|ug|ur|yi|.*[-_](Adlm|Arab|Hebr|Nkoo|Rohg|Thaa))(?!.*[-_](Latn|Cyrl)($|-|_))($|-|_)/i;function ao(n){let i=n?.toLowerCase()||"";return i==="auto"&&typeof navigator<"u"&&navigator?.language?Ir.test(navigator.language)?"rtl":"ltr":i==="rtl"?"rtl":"ltr"}var ae=(()=>{class n{get value(){return this.valueSignal()}valueSignal=j("ltr");change=new B;constructor(){let e=h(br,{optional:!0});if(e){let t=e.body?e.body.dir:null,o=e.documentElement?e.documentElement.dir:null;this.valueSignal.set(ao(t||o||"ltr"))}}ngOnDestroy(){this.change.complete()}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();var Z=(function(n){return n[n.NORMAL=0]="NORMAL",n[n.NEGATED=1]="NEGATED",n[n.INVERTED=2]="INVERTED",n})(Z||{}),$t,Ee;function Vt(){if(Ee==null){if(typeof document!="object"||!document||typeof Element!="function"||!Element)return Ee=!1,Ee;if(document.documentElement?.style&&"scrollBehavior"in document.documentElement.style)Ee=!0;else{let n=Element.prototype.scrollTo;n?Ee=!/\{\s*\[native code\]\s*\}/.test(n.toString()):Ee=!1}}return Ee}function He(){if(typeof document!="object"||!document)return Z.NORMAL;if($t==null){let n=document.createElement("div"),i=n.style;n.dir="rtl",i.width="1px",i.overflow="auto",i.visibility="hidden",i.pointerEvents="none",i.position="absolute";let e=document.createElement("div"),t=e.style;t.width="2px",t.height="1px",n.appendChild(e),document.body.appendChild(n),$t=Z.NORMAL,n.scrollLeft===0&&(n.scrollLeft=1,$t=n.scrollLeft===0?Z.NEGATED:Z.INVERTED),n.remove()}return $t}var fe=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=N({type:n});static \u0275inj=F({})}return n})();var jt=class{};function co(n){return n&&typeof n.connect=="function"&&!(n instanceof mn)}var Ht=class extends jt{_data;constructor(i){super(),this._data=i}connect(){return It(this._data)?this._data:_(this._data)}disconnect(){}},ct=(function(n){return n[n.REPLACED=0]="REPLACED",n[n.INSERTED=1]="INSERTED",n[n.MOVED=2]="MOVED",n[n.REMOVED=3]="REMOVED",n})(ct||{}),Ii=new A("_ViewRepeater"),Gt=class{viewCacheSize=20;_viewCache=[];applyChanges(i,e,t,o,r){i.forEachOperation((s,a,c)=>{let l,d;if(s.previousIndex==null){let u=()=>t(s,a,c);l=this._insertView(u,c,e,o(s)),d=l?ct.INSERTED:ct.REPLACED}else c==null?(this._detachAndCacheView(a,e),d=ct.REMOVED):(l=this._moveView(a,c,e,o(s)),d=ct.MOVED);r&&r({context:l?.context,operation:d,record:s})})}detach(){for(let i of this._viewCache)i.destroy();this._viewCache=[]}_insertView(i,e,t,o){let r=this._insertViewFromCache(e,t);if(r){r.context.$implicit=o;return}let s=i();return t.createEmbeddedView(s.templateRef,s.context,s.index)}_detachAndCacheView(i,e){let t=e.detach(i);this._maybeCacheView(t,e)}_moveView(i,e,t,o){let r=t.get(i);return t.move(r,e),r.context.$implicit=o,r}_maybeCacheView(i,e){if(this._viewCache.length<this.viewCacheSize)this._viewCache.push(i);else{let t=e.indexOf(i);t===-1?i.destroy():e.remove(t)}}_insertViewFromCache(i,e){let t=this._viewCache.pop();return t&&e.insert(t,i),t||null}};var Dr=["contentWrapper"],Er=["*"],uo=new A("VIRTUAL_SCROLL_STRATEGY"),Di=class{_scrolledIndexChange=new y;scrolledIndexChange=this._scrolledIndexChange.pipe(X());_viewport=null;_itemSize;_minBufferPx;_maxBufferPx;constructor(i,e,t){this._itemSize=i,this._minBufferPx=e,this._maxBufferPx=t}attach(i){this._viewport=i,this._updateTotalContentSize(),this._updateRenderedRange()}detach(){this._scrolledIndexChange.complete(),this._viewport=null}updateItemAndBufferSize(i,e,t){t<e,this._itemSize=i,this._minBufferPx=e,this._maxBufferPx=t,this._updateTotalContentSize(),this._updateRenderedRange()}onContentScrolled(){this._updateRenderedRange()}onDataLengthChanged(){this._updateTotalContentSize(),this._updateRenderedRange()}onContentRendered(){}onRenderedOffsetChanged(){}scrollToIndex(i,e){this._viewport&&this._viewport.scrollToOffset(i*this._itemSize,e)}_updateTotalContentSize(){this._viewport&&this._viewport.setTotalContentSize(this._viewport.getDataLength()*this._itemSize)}_updateRenderedRange(){if(!this._viewport)return;let i=this._viewport.getRenderedRange(),e={start:i.start,end:i.end},t=this._viewport.getViewportSize(),o=this._viewport.getDataLength(),r=this._viewport.measureScrollOffset(),s=this._itemSize>0?r/this._itemSize:0;if(e.end>o){let c=Math.ceil(t/this._itemSize),l=Math.max(0,Math.min(s,o-c));s!=l&&(s=l,r=l*this._itemSize,e.start=Math.floor(s)),e.end=Math.max(0,Math.min(o,e.start+c))}let a=r-e.start*this._itemSize;if(a<this._minBufferPx&&e.start!=0){let c=Math.ceil((this._maxBufferPx-a)/this._itemSize);e.start=Math.max(0,e.start-c),e.end=Math.min(o,Math.ceil(s+(t+this._minBufferPx)/this._itemSize))}else{let c=e.end*this._itemSize-(r+t);if(c<this._minBufferPx&&e.end!=o){let l=Math.ceil((this._maxBufferPx-c)/this._itemSize);l>0&&(e.end=Math.min(o,e.end+l),e.start=Math.max(0,Math.floor(s-this._minBufferPx/this._itemSize)))}}this._viewport.setRenderedRange(e),this._viewport.setRenderedContentOffset(Math.round(this._itemSize*e.start)),this._scrolledIndexChange.next(Math.floor(s))}};function Or(n){return n._scrollStrategy}var wr=(()=>{class n{get itemSize(){return this._itemSize}set itemSize(e){this._itemSize=se(e)}_itemSize=20;get minBufferPx(){return this._minBufferPx}set minBufferPx(e){this._minBufferPx=se(e)}_minBufferPx=100;get maxBufferPx(){return this._maxBufferPx}set maxBufferPx(e){this._maxBufferPx=se(e)}_maxBufferPx=200;_scrollStrategy=new Di(this.itemSize,this.minBufferPx,this.maxBufferPx);ngOnChanges(){this._scrollStrategy.updateItemAndBufferSize(this.itemSize,this.minBufferPx,this.maxBufferPx)}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,selectors:[["cdk-virtual-scroll-viewport","itemSize",""]],inputs:{itemSize:"itemSize",minBufferPx:"minBufferPx",maxBufferPx:"maxBufferPx"},features:[ze([{provide:uo,useFactory:Or,deps:[Dn(()=>n)]}]),ie]})}return n})(),Ar=20,lt=(()=>{class n{_ngZone=h(U);_platform=h(H);_renderer=h(oe).createRenderer(null,null);_cleanupGlobalListener;constructor(){}_scrolled=new y;_scrolledCount=0;scrollContainers=new Map;register(e){this.scrollContainers.has(e)||this.scrollContainers.set(e,e.elementScrolled().subscribe(()=>this._scrolled.next(e)))}deregister(e){let t=this.scrollContainers.get(e);t&&(t.unsubscribe(),this.scrollContainers.delete(e))}scrolled(e=Ar){return this._platform.isBrowser?new ye(t=>{this._cleanupGlobalListener||(this._cleanupGlobalListener=this._ngZone.runOutsideAngular(()=>this._renderer.listen("document","scroll",()=>this._scrolled.next())));let o=e>0?this._scrolled.pipe(Ot(e)).subscribe(t):this._scrolled.subscribe(t);return this._scrolledCount++,()=>{o.unsubscribe(),this._scrolledCount--,this._scrolledCount||(this._cleanupGlobalListener?.(),this._cleanupGlobalListener=void 0)}}):_()}ngOnDestroy(){this._cleanupGlobalListener?.(),this._cleanupGlobalListener=void 0,this.scrollContainers.forEach((e,t)=>this.deregister(t)),this._scrolled.complete()}ancestorScrolled(e,t){let o=this.getAncestorScrollContainers(e);return this.scrolled(t).pipe(E(r=>!r||o.indexOf(r)>-1))}getAncestorScrollContainers(e){let t=[];return this.scrollContainers.forEach((o,r)=>{this._scrollableContainsElement(r,e)&&t.push(r)}),t}_scrollableContainsElement(e,t){let o=De(t),r=e.getElementRef().nativeElement;do if(o==r)return!0;while(o=o.parentElement);return!1}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),dt=(()=>{class n{elementRef=h(R);scrollDispatcher=h(lt);ngZone=h(U);dir=h(ae,{optional:!0});_scrollElement=this.elementRef.nativeElement;_destroyed=new y;_renderer=h(Fe);_cleanupScroll;_elementScrolled=new y;constructor(){}ngOnInit(){this._cleanupScroll=this.ngZone.runOutsideAngular(()=>this._renderer.listen(this._scrollElement,"scroll",e=>this._elementScrolled.next(e))),this.scrollDispatcher.register(this)}ngOnDestroy(){this._cleanupScroll?.(),this._elementScrolled.complete(),this.scrollDispatcher.deregister(this),this._destroyed.next(),this._destroyed.complete()}elementScrolled(){return this._elementScrolled}getElementRef(){return this.elementRef}scrollTo(e){let t=this.elementRef.nativeElement,o=this.dir&&this.dir.value=="rtl";e.left==null&&(e.left=o?e.end:e.start),e.right==null&&(e.right=o?e.start:e.end),e.bottom!=null&&(e.top=t.scrollHeight-t.clientHeight-e.bottom),o&&He()!=Z.NORMAL?(e.left!=null&&(e.right=t.scrollWidth-t.clientWidth-e.left),He()==Z.INVERTED?e.left=e.right:He()==Z.NEGATED&&(e.left=e.right?-e.right:e.right)):e.right!=null&&(e.left=t.scrollWidth-t.clientWidth-e.right),this._applyScrollToOptions(e)}_applyScrollToOptions(e){let t=this.elementRef.nativeElement;Vt()?t.scrollTo(e):(e.top!=null&&(t.scrollTop=e.top),e.left!=null&&(t.scrollLeft=e.left))}measureScrollOffset(e){let t="left",o="right",r=this.elementRef.nativeElement;if(e=="top")return r.scrollTop;if(e=="bottom")return r.scrollHeight-r.clientHeight-r.scrollTop;let s=this.dir&&this.dir.value=="rtl";return e=="start"?e=s?o:t:e=="end"&&(e=s?t:o),s&&He()==Z.INVERTED?e==t?r.scrollWidth-r.clientWidth-r.scrollLeft:r.scrollLeft:s&&He()==Z.NEGATED?e==t?r.scrollLeft+r.scrollWidth-r.clientWidth:-r.scrollLeft:e==t?r.scrollLeft:r.scrollWidth-r.clientWidth-r.scrollLeft}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,selectors:[["","cdk-scrollable",""],["","cdkScrollable",""]]})}return n})(),Rr=20,Oe=(()=>{class n{_platform=h(H);_listeners;_viewportSize;_change=new y;_document=h(M);constructor(){let e=h(U),t=h(oe).createRenderer(null,null);e.runOutsideAngular(()=>{if(this._platform.isBrowser){let o=r=>this._change.next(r);this._listeners=[t.listen("window","resize",o),t.listen("window","orientationchange",o)]}this.change().subscribe(()=>this._viewportSize=null)})}ngOnDestroy(){this._listeners?.forEach(e=>e()),this._change.complete()}getViewportSize(){this._viewportSize||this._updateViewportSize();let e={width:this._viewportSize.width,height:this._viewportSize.height};return this._platform.isBrowser||(this._viewportSize=null),e}getViewportRect(){let e=this.getViewportScrollPosition(),{width:t,height:o}=this.getViewportSize();return{top:e.top,left:e.left,bottom:e.top+o,right:e.left+t,height:o,width:t}}getViewportScrollPosition(){if(!this._platform.isBrowser)return{top:0,left:0};let e=this._document,t=this._getWindow(),o=e.documentElement,r=o.getBoundingClientRect(),s=-r.top||e.body.scrollTop||t.scrollY||o.scrollTop||0,a=-r.left||e.body.scrollLeft||t.scrollX||o.scrollLeft||0;return{top:s,left:a}}change(e=Rr){return e>0?this._change.pipe(Ot(e)):this._change}_getWindow(){return this._document.defaultView||window}_updateViewportSize(){let e=this._getWindow();this._viewportSize=this._platform.isBrowser?{width:e.innerWidth,height:e.innerHeight}:{width:0,height:0}}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),lo=new A("VIRTUAL_SCROLLABLE"),kr=(()=>{class n extends dt{constructor(){super()}measureViewportSize(e){let t=this.elementRef.nativeElement;return e==="horizontal"?t.clientWidth:t.clientHeight}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,features:[W]})}return n})();function Tr(n,i){return n.start==i.start&&n.end==i.end}var xr=typeof requestAnimationFrame<"u"?vn:_n,fo=(()=>{class n extends kr{elementRef=h(R);_changeDetectorRef=h($e);_scrollStrategy=h(uo,{optional:!0});scrollable=h(lo,{optional:!0});_platform=h(H);_detachedSubject=new y;_renderedRangeSubject=new y;get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._orientation=e,this._calculateSpacerSize())}_orientation="vertical";appendOnly=!1;scrolledIndexChange=new ye(e=>this._scrollStrategy.scrolledIndexChange.subscribe(t=>Promise.resolve().then(()=>this.ngZone.run(()=>e.next(t)))));_contentWrapper;renderedRangeStream=this._renderedRangeSubject;_totalContentSize=0;_totalContentWidth=j("");_totalContentHeight=j("");_renderedContentTransform;_renderedRange={start:0,end:0};_dataLength=0;_viewportSize=0;_forOf;_renderedContentOffset=0;_renderedContentOffsetNeedsRewrite=!1;_changeDetectionNeeded=j(!1);_runAfterChangeDetection=[];_viewportChanges=K.EMPTY;_injector=h(O);_isDestroyed=!1;constructor(){super();let e=h(Oe);this._scrollStrategy,this._viewportChanges=e.change().subscribe(()=>{this.checkViewportSize()}),this.scrollable||(this.elementRef.nativeElement.classList.add("cdk-virtual-scrollable"),this.scrollable=this);let t=Be(()=>{this._changeDetectionNeeded()&&this._doChangeDetection()},{injector:h(Ne).injector});h(En).onDestroy(()=>{t.destroy()})}ngOnInit(){this._platform.isBrowser&&(this.scrollable===this&&super.ngOnInit(),this.ngZone.runOutsideAngular(()=>Promise.resolve().then(()=>{this._measureViewportSize(),this._scrollStrategy.attach(this),this.scrollable.elementScrolled().pipe(Ce(null),Ot(0,xr),de(this._destroyed)).subscribe(()=>this._scrollStrategy.onContentScrolled()),this._markChangeDetectionNeeded()})))}ngOnDestroy(){this.detach(),this._scrollStrategy.detach(),this._renderedRangeSubject.complete(),this._detachedSubject.complete(),this._viewportChanges.unsubscribe(),this._isDestroyed=!0,super.ngOnDestroy()}attach(e){this._forOf,this.ngZone.runOutsideAngular(()=>{this._forOf=e,this._forOf.dataStream.pipe(de(this._detachedSubject)).subscribe(t=>{let o=t.length;o!==this._dataLength&&(this._dataLength=o,this._scrollStrategy.onDataLengthChanged()),this._doChangeDetection()})})}detach(){this._forOf=null,this._detachedSubject.next()}getDataLength(){return this._dataLength}getViewportSize(){return this._viewportSize}getRenderedRange(){return this._renderedRange}measureBoundingClientRectWithScrollOffset(e){return this.getElementRef().nativeElement.getBoundingClientRect()[e]}setTotalContentSize(e){this._totalContentSize!==e&&(this._totalContentSize=e,this._calculateSpacerSize(),this._markChangeDetectionNeeded())}setRenderedRange(e){Tr(this._renderedRange,e)||(this.appendOnly&&(e={start:0,end:Math.max(this._renderedRange.end,e.end)}),this._renderedRangeSubject.next(this._renderedRange=e),this._markChangeDetectionNeeded(()=>this._scrollStrategy.onContentRendered()))}getOffsetToRenderedContentStart(){return this._renderedContentOffsetNeedsRewrite?null:this._renderedContentOffset}setRenderedContentOffset(e,t="to-start"){e=this.appendOnly&&t==="to-start"?0:e;let o=this.dir&&this.dir.value=="rtl",r=this.orientation=="horizontal",s=r?"X":"Y",c=`translate${s}(${Number((r&&o?-1:1)*e)}px)`;this._renderedContentOffset=e,t==="to-end"&&(c+=` translate${s}(-100%)`,this._renderedContentOffsetNeedsRewrite=!0),this._renderedContentTransform!=c&&(this._renderedContentTransform=c,this._markChangeDetectionNeeded(()=>{this._renderedContentOffsetNeedsRewrite?(this._renderedContentOffset-=this.measureRenderedContentSize(),this._renderedContentOffsetNeedsRewrite=!1,this.setRenderedContentOffset(this._renderedContentOffset)):this._scrollStrategy.onRenderedOffsetChanged()}))}scrollToOffset(e,t="auto"){let o={behavior:t};this.orientation==="horizontal"?o.start=e:o.top=e,this.scrollable.scrollTo(o)}scrollToIndex(e,t="auto"){this._scrollStrategy.scrollToIndex(e,t)}measureScrollOffset(e){let t;return this.scrollable==this?t=o=>super.measureScrollOffset(o):t=o=>this.scrollable.measureScrollOffset(o),Math.max(0,t(e??(this.orientation==="horizontal"?"start":"top"))-this.measureViewportOffset())}measureViewportOffset(e){let t,o="left",r="right",s=this.dir?.value=="rtl";e=="start"?t=s?r:o:e=="end"?t=s?o:r:e?t=e:t=this.orientation==="horizontal"?"left":"top";let a=this.scrollable.measureBoundingClientRectWithScrollOffset(t);return this.elementRef.nativeElement.getBoundingClientRect()[t]-a}measureRenderedContentSize(){let e=this._contentWrapper.nativeElement;return this.orientation==="horizontal"?e.offsetWidth:e.offsetHeight}measureRangeSize(e){return this._forOf?this._forOf.measureRangeSize(e,this.orientation):0}checkViewportSize(){this._measureViewportSize(),this._scrollStrategy.onDataLengthChanged()}_measureViewportSize(){this._viewportSize=this.scrollable.measureViewportSize(this.orientation)}_markChangeDetectionNeeded(e){e&&this._runAfterChangeDetection.push(e),!Bn(this._changeDetectionNeeded)&&this.ngZone.runOutsideAngular(()=>{Promise.resolve().then(()=>{this.ngZone.run(()=>{this._changeDetectionNeeded.set(!0)})})})}_doChangeDetection(){this._isDestroyed||this.ngZone.run(()=>{this._changeDetectorRef.markForCheck(),this._contentWrapper.nativeElement.style.transform=this._renderedContentTransform,ne(()=>{this._changeDetectionNeeded.set(!1);let e=this._runAfterChangeDetection;this._runAfterChangeDetection=[];for(let t of e)t()},{injector:this._injector})})}_calculateSpacerSize(){this._totalContentHeight.set(this.orientation==="horizontal"?"":`${this._totalContentSize}px`),this._totalContentWidth.set(this.orientation==="horizontal"?`${this._totalContentSize}px`:"")}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=G({type:n,selectors:[["cdk-virtual-scroll-viewport"]],viewQuery:function(t,o){if(t&1&&Tt(Dr,7),t&2){let r;xt(r=Pt())&&(o._contentWrapper=r.first)}},hostAttrs:[1,"cdk-virtual-scroll-viewport"],hostVars:4,hostBindings:function(t,o){t&2&&nt("cdk-virtual-scroll-orientation-horizontal",o.orientation==="horizontal")("cdk-virtual-scroll-orientation-vertical",o.orientation!=="horizontal")},inputs:{orientation:"orientation",appendOnly:[2,"appendOnly","appendOnly",q]},outputs:{scrolledIndexChange:"scrolledIndexChange"},features:[ze([{provide:dt,useFactory:(e,t)=>e||t,deps:[[new wn,new On(lo)],n]}]),W],ngContentSelectors:Er,decls:4,vars:4,consts:[["contentWrapper",""],[1,"cdk-virtual-scroll-content-wrapper"],[1,"cdk-virtual-scroll-spacer"]],template:function(t,o){t&1&&(Un(),Pn(0,"div",1,0),Nn(2),Mn(),Ln(3,"div",2)),t&2&&(Rn(3),zn("width",o._totalContentWidth())("height",o._totalContentHeight()))},styles:[`cdk-virtual-scroll-viewport{display:block;position:relative;transform:translateZ(0)}.cdk-virtual-scrollable{overflow:auto;will-change:scroll-position;contain:strict}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{height:1px;transform-origin:0 0;flex:0 0 auto}[dir=rtl] .cdk-virtual-scroll-spacer{transform-origin:100% 0}
2
2
  `],encapsulation:2,changeDetection:0})}return n})();function ho(n,i,e){let t=e;if(!t.getBoundingClientRect)return 0;let o=t.getBoundingClientRect();return n==="horizontal"?i==="start"?o.left:o.right:i==="start"?o.top:o.bottom}var Pr=(()=>{class n{_viewContainerRef=h(Ue);_template=h(be);_differs=h($n);_viewRepeater=h(Ii);_viewport=h(fo,{skipSelf:!0});viewChange=new y;_dataSourceChanges=new y;get cdkVirtualForOf(){return this._cdkVirtualForOf}set cdkVirtualForOf(e){this._cdkVirtualForOf=e,co(e)?this._dataSourceChanges.next(e):this._dataSourceChanges.next(new Ht(It(e)?e:Array.from(e||[])))}_cdkVirtualForOf;get cdkVirtualForTrackBy(){return this._cdkVirtualForTrackBy}set cdkVirtualForTrackBy(e){this._needsUpdate=!0,this._cdkVirtualForTrackBy=e?(t,o)=>e(t+(this._renderedRange?this._renderedRange.start:0),o):void 0}_cdkVirtualForTrackBy;set cdkVirtualForTemplate(e){e&&(this._needsUpdate=!0,this._template=e)}get cdkVirtualForTemplateCacheSize(){return this._viewRepeater.viewCacheSize}set cdkVirtualForTemplateCacheSize(e){this._viewRepeater.viewCacheSize=se(e)}dataStream=this._dataSourceChanges.pipe(Ce(null),yn(),v(([e,t])=>this._changeDataSource(e,t)),Cn(1));_differ=null;_data;_renderedItems;_renderedRange;_needsUpdate=!1;_destroyed=new y;constructor(){let e=h(U);this.dataStream.subscribe(t=>{this._data=t,this._onRenderedDataChange()}),this._viewport.renderedRangeStream.pipe(de(this._destroyed)).subscribe(t=>{this._renderedRange=t,this.viewChange.observers.length&&e.run(()=>this.viewChange.next(this._renderedRange)),this._onRenderedDataChange()}),this._viewport.attach(this)}measureRangeSize(e,t){if(e.start>=e.end)return 0;e.start<this._renderedRange.start||e.end>this._renderedRange.end;let o=e.start-this._renderedRange.start,r=e.end-e.start,s,a;for(let c=0;c<r;c++){let l=this._viewContainerRef.get(c+o);if(l&&l.rootNodes.length){s=a=l.rootNodes[0];break}}for(let c=r-1;c>-1;c--){let l=this._viewContainerRef.get(c+o);if(l&&l.rootNodes.length){a=l.rootNodes[l.rootNodes.length-1];break}}return s&&a?ho(t,"end",a)-ho(t,"start",s):0}ngDoCheck(){if(this._differ&&this._needsUpdate){let e=this._differ.diff(this._renderedItems);e?this._applyChanges(e):this._updateContext(),this._needsUpdate=!1}}ngOnDestroy(){this._viewport.detach(),this._dataSourceChanges.next(void 0),this._dataSourceChanges.complete(),this.viewChange.complete(),this._destroyed.next(),this._destroyed.complete(),this._viewRepeater.detach()}_onRenderedDataChange(){this._renderedRange&&(this._renderedItems=this._data.slice(this._renderedRange.start,this._renderedRange.end),this._differ||(this._differ=this._differs.find(this._renderedItems).create((e,t)=>this.cdkVirtualForTrackBy?this.cdkVirtualForTrackBy(e,t):t)),this._needsUpdate=!0)}_changeDataSource(e,t){return e&&e.disconnect(this),this._needsUpdate=!0,t?t.connect(this):_()}_updateContext(){let e=this._data.length,t=this._viewContainerRef.length;for(;t--;){let o=this._viewContainerRef.get(t);o.context.index=this._renderedRange.start+t,o.context.count=e,this._updateComputedContextProperties(o.context),o.detectChanges()}}_applyChanges(e){this._viewRepeater.applyChanges(e,this._viewContainerRef,(r,s,a)=>this._getEmbeddedViewArgs(r,a),r=>r.item),e.forEachIdentityChange(r=>{let s=this._viewContainerRef.get(r.currentIndex);s.context.$implicit=r.item});let t=this._data.length,o=this._viewContainerRef.length;for(;o--;){let r=this._viewContainerRef.get(o);r.context.index=this._renderedRange.start+o,r.context.count=t,this._updateComputedContextProperties(r.context)}}_updateComputedContextProperties(e){e.first=e.index===0,e.last=e.index===e.count-1,e.even=e.index%2===0,e.odd=!e.even}_getEmbeddedViewArgs(e,t){return{templateRef:this._template,context:{$implicit:e.item,cdkVirtualForOf:this._cdkVirtualForOf,index:-1,count:-1,first:!1,last:!1,odd:!1,even:!1},index:t}}static ngTemplateContextGuard(e,t){return!0}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,selectors:[["","cdkVirtualFor","","cdkVirtualForOf",""]],inputs:{cdkVirtualForOf:"cdkVirtualForOf",cdkVirtualForTrackBy:"cdkVirtualForTrackBy",cdkVirtualForTemplate:"cdkVirtualForTemplate",cdkVirtualForTemplateCacheSize:"cdkVirtualForTemplateCacheSize"},features:[ze([{provide:Ii,useClass:Gt}])]})}return n})();var Ei=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=N({type:n});static \u0275inj=F({})}return n})(),Oi=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=N({type:n});static \u0275inj=F({imports:[fe,Ei,fe,Ei]})}return n})();var ht=class{_attachedHost;attach(i){return this._attachedHost=i,i.attach(this)}detach(){let i=this._attachedHost;i!=null&&(this._attachedHost=null,i.detach())}get isAttached(){return this._attachedHost!=null}setAttachedHost(i){this._attachedHost=i}},Ge=class extends ht{component;viewContainerRef;injector;projectableNodes;constructor(i,e,t,o){super(),this.component=i,this.viewContainerRef=e,this.injector=t,this.projectableNodes=o}},we=class extends ht{templateRef;viewContainerRef;context;injector;constructor(i,e,t,o){super(),this.templateRef=i,this.viewContainerRef=e,this.context=t,this.injector=o}get origin(){return this.templateRef.elementRef}attach(i,e=this.context){return this.context=e,super.attach(i)}detach(){return this.context=void 0,super.detach()}},wi=class extends ht{element;constructor(i){super(),this.element=i instanceof R?i.nativeElement:i}},We=class{_attachedPortal;_disposeFn;_isDisposed=!1;hasAttached(){return!!this._attachedPortal}attach(i){if(i instanceof Ge)return this._attachedPortal=i,this.attachComponentPortal(i);if(i instanceof we)return this._attachedPortal=i,this.attachTemplatePortal(i);if(this.attachDomPortal&&i instanceof wi)return this._attachedPortal=i,this.attachDomPortal(i)}attachDomPortal=null;detach(){this._attachedPortal&&(this._attachedPortal.setAttachedHost(null),this._attachedPortal=null),this._invokeDisposeFn()}dispose(){this.hasAttached()&&this.detach(),this._invokeDisposeFn(),this._isDisposed=!0}setDisposeFn(i){this._disposeFn=i}_invokeDisposeFn(){this._disposeFn&&(this._disposeFn(),this._disposeFn=null)}},Wt=class extends We{outletElement;_appRef;_defaultInjector;constructor(i,e,t){super(),this.outletElement=i,this._appRef=e,this._defaultInjector=t}attachComponentPortal(i){let e;if(i.viewContainerRef){let t=i.injector||i.viewContainerRef.injector,o=t.get(mi,null,{optional:!0})||void 0;e=i.viewContainerRef.createComponent(i.component,{index:i.viewContainerRef.length,injector:t,ngModuleRef:o,projectableNodes:i.projectableNodes||void 0}),this.setDisposeFn(()=>e.destroy())}else{let t=this._appRef,o=i.injector||this._defaultInjector||O.NULL,r=o.get(Me,t.injector);e=Mt(i.component,{elementInjector:o,environmentInjector:r,projectableNodes:i.projectableNodes||void 0}),t.attachView(e.hostView),this.setDisposeFn(()=>{t.viewCount>0&&t.detachView(e.hostView),e.destroy()})}return this.outletElement.appendChild(this._getComponentRootNode(e)),this._attachedPortal=i,e}attachTemplatePortal(i){let e=i.viewContainerRef,t=e.createEmbeddedView(i.templateRef,i.context,{injector:i.injector});return t.rootNodes.forEach(o=>this.outletElement.appendChild(o)),t.detectChanges(),this.setDisposeFn(()=>{let o=e.indexOf(t);o!==-1&&e.remove(o)}),this._attachedPortal=i,t}attachDomPortal=i=>{let e=i.element;e.parentNode;let t=this.outletElement.ownerDocument.createComment("dom-portal");e.parentNode.insertBefore(t,e),this.outletElement.appendChild(e),this._attachedPortal=i,super.setDisposeFn(()=>{t.parentNode&&t.parentNode.replaceChild(e,t)})};dispose(){super.dispose(),this.outletElement.remove()}_getComponentRootNode(i){return i.hostView.rootNodes[0]}};var ut=(()=>{class n extends We{_moduleRef=h(mi,{optional:!0});_document=h(M);_viewContainerRef=h(Ue);_isInitialized=!1;_attachedRef;constructor(){super()}get portal(){return this._attachedPortal}set portal(e){this.hasAttached()&&!e&&!this._isInitialized||(this.hasAttached()&&super.detach(),e&&super.attach(e),this._attachedPortal=e||null)}attached=new B;get attachedRef(){return this._attachedRef}ngOnInit(){this._isInitialized=!0}ngOnDestroy(){super.dispose(),this._attachedRef=this._attachedPortal=null}attachComponentPortal(e){e.setAttachedHost(this);let t=e.viewContainerRef!=null?e.viewContainerRef:this._viewContainerRef,o=t.createComponent(e.component,{index:t.length,injector:e.injector||t.injector,projectableNodes:e.projectableNodes||void 0,ngModuleRef:this._moduleRef||void 0});return t!==this._viewContainerRef&&this._getRootNode().appendChild(o.hostView.rootNodes[0]),super.setDisposeFn(()=>o.destroy()),this._attachedPortal=e,this._attachedRef=o,this.attached.emit(o),o}attachTemplatePortal(e){e.setAttachedHost(this);let t=this._viewContainerRef.createEmbeddedView(e.templateRef,e.context,{injector:e.injector});return super.setDisposeFn(()=>this._viewContainerRef.clear()),this._attachedPortal=e,this._attachedRef=t,this.attached.emit(t),t}attachDomPortal=e=>{let t=e.element;t.parentNode;let o=this._document.createComment("dom-portal");e.setAttachedHost(this),t.parentNode.insertBefore(o,t),this._getRootNode().appendChild(t),this._attachedPortal=e,super.setDisposeFn(()=>{o.parentNode&&o.parentNode.replaceChild(t,o)})};_getRootNode(){let e=this._viewContainerRef.element.nativeElement;return e.nodeType===e.ELEMENT_NODE?e:e.parentNode}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,selectors:[["","cdkPortalOutlet",""]],inputs:{portal:[0,"cdkPortalOutlet","portal"]},outputs:{attached:"attached"},exportAs:["cdkPortalOutlet"],features:[W]})}return n})();var Ae=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=N({type:n});static \u0275inj=F({})}return n})();var Ai;function Lr(){if(Ai==null){let n=typeof document<"u"?document.head:null;Ai=!!(n&&(n.createShadowRoot||n.attachShadow))}return Ai}function po(n){if(Lr()){let i=n.getRootNode?n.getRootNode():null;if(typeof ShadowRoot<"u"&&ShadowRoot&&i instanceof ShadowRoot)return i}return null}function Yt(){let n=typeof document<"u"&&document?document.activeElement:null;for(;n&&n.shadowRoot;){let i=n.shadowRoot.activeElement;if(i===n)break;n=i}return n}function ee(n){return n.composedPath?n.composedPath()[0]:n.target}function Ri(){return typeof __karma__<"u"&&!!__karma__||typeof jasmine<"u"&&!!jasmine||typeof jest<"u"&&!!jest||typeof Mocha<"u"&&!!Mocha}var Kt=new WeakMap,Ye=(()=>{class n{_appRef;_injector=h(O);_environmentInjector=h(Me);load(e){let t=this._appRef=this._appRef||this._injector.get(Ne),o=Kt.get(t);o||(o={loaders:new Set,refs:[]},Kt.set(t,o),t.onDestroy(()=>{Kt.get(t)?.refs.forEach(r=>r.destroy()),Kt.delete(t)})),o.loaders.has(e)||(o.loaders.add(e),o.refs.push(Mt(e,{environmentInjector:this._environmentInjector})))}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function P(n){return n==null?"":typeof n=="string"?n:`${n}px`}var ki={},pe=(()=>{class n{_appId=h(An);getId(e){return this._appId!=="ng"&&(e+=this._appId),ki.hasOwnProperty(e)||(ki[e]=0),`${e}${ki[e]++}`}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function ge(n,...i){return i.length?i.some(e=>n[e]):n.altKey||n.shiftKey||n.ctrlKey||n.metaKey}var go=Vt();function Xe(n){return new Xt(n.get(Oe),n.get(M))}var Xt=class{_viewportRuler;_previousHTMLStyles={top:"",left:""};_previousScrollPosition;_isEnabled=!1;_document;constructor(i,e){this._viewportRuler=i,this._document=e}attach(){}enable(){if(this._canBeEnabled()){let i=this._document.documentElement;this._previousScrollPosition=this._viewportRuler.getViewportScrollPosition(),this._previousHTMLStyles.left=i.style.left||"",this._previousHTMLStyles.top=i.style.top||"",i.style.left=P(-this._previousScrollPosition.left),i.style.top=P(-this._previousScrollPosition.top),i.classList.add("cdk-global-scrollblock"),this._isEnabled=!0}}disable(){if(this._isEnabled){let i=this._document.documentElement,e=this._document.body,t=i.style,o=e.style,r=t.scrollBehavior||"",s=o.scrollBehavior||"";this._isEnabled=!1,t.left=this._previousHTMLStyles.left,t.top=this._previousHTMLStyles.top,i.classList.remove("cdk-global-scrollblock"),go&&(t.scrollBehavior=o.scrollBehavior="auto"),window.scroll(this._previousScrollPosition.left,this._previousScrollPosition.top),go&&(t.scrollBehavior=r,o.scrollBehavior=s)}}_canBeEnabled(){if(this._document.documentElement.classList.contains("cdk-global-scrollblock")||this._isEnabled)return!1;let e=this._document.documentElement,t=this._viewportRuler.getViewportSize();return e.scrollHeight>t.height||e.scrollWidth>t.width}};function So(n,i){return new Zt(n.get(lt),n.get(U),n.get(Oe),i)}var Zt=class{_scrollDispatcher;_ngZone;_viewportRuler;_config;_scrollSubscription=null;_overlayRef;_initialScrollPosition;constructor(i,e,t,o){this._scrollDispatcher=i,this._ngZone=e,this._viewportRuler=t,this._config=o}attach(i){this._overlayRef,this._overlayRef=i}enable(){if(this._scrollSubscription)return;let i=this._scrollDispatcher.scrolled(0).pipe(E(e=>!e||!this._overlayRef.overlayElement.contains(e.getElementRef().nativeElement)));this._config&&this._config.threshold&&this._config.threshold>1?(this._initialScrollPosition=this._viewportRuler.getViewportScrollPosition().top,this._scrollSubscription=i.subscribe(()=>{let e=this._viewportRuler.getViewportScrollPosition().top;Math.abs(e-this._initialScrollPosition)>this._config.threshold?this._detach():this._overlayRef.updatePosition()})):this._scrollSubscription=i.subscribe(this._detach)}disable(){this._scrollSubscription&&(this._scrollSubscription.unsubscribe(),this._scrollSubscription=null)}detach(){this.disable(),this._overlayRef=null}_detach=()=>{this.disable(),this._overlayRef.hasAttached()&&this._ngZone.run(()=>this._overlayRef.detach())}};var ft=class{enable(){}disable(){}attach(){}};function Ti(n,i){return i.some(e=>{let t=n.bottom<e.top,o=n.top>e.bottom,r=n.right<e.left,s=n.left>e.right;return t||o||r||s})}function mo(n,i){return i.some(e=>{let t=n.top<e.top,o=n.bottom>e.bottom,r=n.left<e.left,s=n.right>e.right;return t||o||r||s})}function ti(n,i){return new Qt(n.get(lt),n.get(Oe),n.get(U),i)}var Qt=class{_scrollDispatcher;_viewportRuler;_ngZone;_config;_scrollSubscription=null;_overlayRef;constructor(i,e,t,o){this._scrollDispatcher=i,this._viewportRuler=e,this._ngZone=t,this._config=o}attach(i){this._overlayRef,this._overlayRef=i}enable(){if(!this._scrollSubscription){let i=this._config?this._config.scrollThrottle:0;this._scrollSubscription=this._scrollDispatcher.scrolled(i).subscribe(()=>{if(this._overlayRef.updatePosition(),this._config&&this._config.autoClose){let e=this._overlayRef.overlayElement.getBoundingClientRect(),{width:t,height:o}=this._viewportRuler.getViewportSize();Ti(e,[{width:t,height:o,bottom:o,right:t,top:0,left:0}])&&(this.disable(),this._ngZone.run(()=>this._overlayRef.detach()))}})}}disable(){this._scrollSubscription&&(this._scrollSubscription.unsubscribe(),this._scrollSubscription=null)}detach(){this.disable(),this._overlayRef=null}},Io=(()=>{class n{_injector=h(O);constructor(){}noop=()=>new ft;close=e=>So(this._injector,e);block=()=>Xe(this._injector);reposition=e=>ti(this._injector,e);static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),ke=class{positionStrategy;scrollStrategy=new ft;panelClass="";hasBackdrop=!1;backdropClass="cdk-overlay-dark-backdrop";disableAnimations;width;height;minWidth;minHeight;maxWidth;maxHeight;direction;disposeOnNavigation=!1;constructor(i){if(i){let e=Object.keys(i);for(let t of e)i[t]!==void 0&&(this[t]=i[t])}}},xi=class{offsetX;offsetY;panelClass;originX;originY;overlayX;overlayY;constructor(i,e,t,o,r){this.offsetX=t,this.offsetY=o,this.panelClass=r,this.originX=i.originX,this.originY=i.originY,this.overlayX=e.overlayX,this.overlayY=e.overlayY}};var qt=class{connectionPair;scrollableViewProperties;constructor(i,e){this.connectionPair=i,this.scrollableViewProperties=e}};var Do=(()=>{class n{_attachedOverlays=[];_document=h(M);_isAttached;constructor(){}ngOnDestroy(){this.detach()}add(e){this.remove(e),this._attachedOverlays.push(e)}remove(e){let t=this._attachedOverlays.indexOf(e);t>-1&&this._attachedOverlays.splice(t,1),this._attachedOverlays.length===0&&this.detach()}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),Eo=(()=>{class n extends Do{_ngZone=h(U);_renderer=h(oe).createRenderer(null,null);_cleanupKeydown;add(e){super.add(e),this._isAttached||(this._ngZone.runOutsideAngular(()=>{this._cleanupKeydown=this._renderer.listen("body","keydown",this._keydownListener)}),this._isAttached=!0)}detach(){this._isAttached&&(this._cleanupKeydown?.(),this._isAttached=!1)}_keydownListener=e=>{let t=this._attachedOverlays;for(let o=t.length-1;o>-1;o--)if(t[o]._keydownEvents.observers.length>0){this._ngZone.run(()=>t[o]._keydownEvents.next(e));break}};static \u0275fac=(()=>{let e;return function(o){return(e||(e=he(n)))(o||n)}})();static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),Oo=(()=>{class n extends Do{_platform=h(H);_ngZone=h(U);_renderer=h(oe).createRenderer(null,null);_cursorOriginalValue;_cursorStyleIsSet=!1;_pointerDownEventTarget;_cleanups;add(e){if(super.add(e),!this._isAttached){let t=this._document.body,o={capture:!0},r=this._renderer;this._cleanups=this._ngZone.runOutsideAngular(()=>[r.listen(t,"pointerdown",this._pointerDownListener,o),r.listen(t,"click",this._clickListener,o),r.listen(t,"auxclick",this._clickListener,o),r.listen(t,"contextmenu",this._clickListener,o)]),this._platform.IOS&&!this._cursorStyleIsSet&&(this._cursorOriginalValue=t.style.cursor,t.style.cursor="pointer",this._cursorStyleIsSet=!0),this._isAttached=!0}}detach(){this._isAttached&&(this._cleanups?.forEach(e=>e()),this._cleanups=void 0,this._platform.IOS&&this._cursorStyleIsSet&&(this._document.body.style.cursor=this._cursorOriginalValue,this._cursorStyleIsSet=!1),this._isAttached=!1)}_pointerDownListener=e=>{this._pointerDownEventTarget=ee(e)};_clickListener=e=>{let t=ee(e),o=e.type==="click"&&this._pointerDownEventTarget?this._pointerDownEventTarget:t;this._pointerDownEventTarget=null;let r=this._attachedOverlays.slice();for(let s=r.length-1;s>-1;s--){let a=r[s];if(a._outsidePointerEvents.observers.length<1||!a.hasAttached())continue;if(_o(a.overlayElement,t)||_o(a.overlayElement,o))break;let c=a._outsidePointerEvents;this._ngZone?this._ngZone.run(()=>c.next(e)):c.next(e)}};static \u0275fac=(()=>{let e;return function(o){return(e||(e=he(n)))(o||n)}})();static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function _o(n,i){let e=typeof ShadowRoot<"u"&&ShadowRoot,t=i;for(;t;){if(t===n)return!0;t=e&&t instanceof ShadowRoot?t.host:t.parentNode}return!1}var wo=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275cmp=G({type:n,selectors:[["ng-component"]],hostAttrs:["cdk-overlay-style-loader",""],decls:0,vars:0,template:function(t,o){},styles:[`.cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}.cdk-overlay-container{position:fixed}@layer cdk-overlay{.cdk-overlay-container{z-index:1000}}.cdk-overlay-container:empty{display:none}.cdk-global-overlay-wrapper{display:flex;position:absolute}@layer cdk-overlay{.cdk-global-overlay-wrapper{z-index:1000}}.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%}@layer cdk-overlay{.cdk-overlay-pane{z-index:1000}}.cdk-overlay-backdrop{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:auto;-webkit-tap-highlight-color:rgba(0,0,0,0);opacity:0;touch-action:manipulation}@layer cdk-overlay{.cdk-overlay-backdrop{z-index:1000;transition:opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}}@media(prefers-reduced-motion){.cdk-overlay-backdrop{transition-duration:1ms}}.cdk-overlay-backdrop-showing{opacity:1}@media(forced-colors: active){.cdk-overlay-backdrop-showing{opacity:.6}}@layer cdk-overlay{.cdk-overlay-dark-backdrop{background:rgba(0,0,0,.32)}}.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}.cdk-overlay-backdrop-noop-animation{transition:none}.cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px}@layer cdk-overlay{.cdk-overlay-connected-position-bounding-box{z-index:1000}}.cdk-global-scrollblock{position:fixed;width:100%;overflow-y:scroll}
3
3
  `],encapsulation:2,changeDetection:0})}return n})(),ii=(()=>{class n{_platform=h(H);_containerElement;_document=h(M);_styleLoader=h(Ye);constructor(){}ngOnDestroy(){this._containerElement?.remove()}getContainerElement(){return this._loadStyles(),this._containerElement||this._createContainer(),this._containerElement}_createContainer(){let e="cdk-overlay-container";if(this._platform.isBrowser||Ri()){let o=this._document.querySelectorAll(`.${e}[platform="server"], .${e}[platform="test"]`);for(let r=0;r<o.length;r++)o[r].remove()}let t=this._document.createElement("div");t.classList.add(e),Ri()?t.setAttribute("platform","test"):this._platform.isBrowser||t.setAttribute("platform","server"),this._document.body.appendChild(t),this._containerElement=t}_loadStyles(){this._styleLoader.load(wo)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),Pi=class{_renderer;_ngZone;element;_cleanupClick;_cleanupTransitionEnd;_fallbackTimeout;constructor(i,e,t,o){this._renderer=e,this._ngZone=t,this.element=i.createElement("div"),this.element.classList.add("cdk-overlay-backdrop"),this._cleanupClick=e.listen(this.element,"click",o)}detach(){this._ngZone.runOutsideAngular(()=>{let i=this.element;clearTimeout(this._fallbackTimeout),this._cleanupTransitionEnd?.(),this._cleanupTransitionEnd=this._renderer.listen(i,"transitionend",this.dispose),this._fallbackTimeout=setTimeout(this.dispose,500),i.style.pointerEvents="none",i.classList.remove("cdk-overlay-backdrop-showing")})}dispose=()=>{clearTimeout(this._fallbackTimeout),this._cleanupClick?.(),this._cleanupTransitionEnd?.(),this._cleanupClick=this._cleanupTransitionEnd=this._fallbackTimeout=void 0,this.element.remove()}},Ke=class{_portalOutlet;_host;_pane;_config;_ngZone;_keyboardDispatcher;_document;_location;_outsideClickDispatcher;_animationsDisabled;_injector;_renderer;_backdropClick=new y;_attachments=new y;_detachments=new y;_positionStrategy;_scrollStrategy;_locationChanges=K.EMPTY;_backdropRef=null;_detachContentMutationObserver;_detachContentAfterRenderRef;_previousHostParent;_keydownEvents=new y;_outsidePointerEvents=new y;_afterNextRenderRef;constructor(i,e,t,o,r,s,a,c,l,d=!1,u,p){this._portalOutlet=i,this._host=e,this._pane=t,this._config=o,this._ngZone=r,this._keyboardDispatcher=s,this._document=a,this._location=c,this._outsideClickDispatcher=l,this._animationsDisabled=d,this._injector=u,this._renderer=p,o.scrollStrategy&&(this._scrollStrategy=o.scrollStrategy,this._scrollStrategy.attach(this)),this._positionStrategy=o.positionStrategy}get overlayElement(){return this._pane}get backdropElement(){return this._backdropRef?.element||null}get hostElement(){return this._host}attach(i){!this._host.parentElement&&this._previousHostParent&&this._previousHostParent.appendChild(this._host);let e=this._portalOutlet.attach(i);return this._positionStrategy&&this._positionStrategy.attach(this),this._updateStackingOrder(),this._updateElementSize(),this._updateElementDirection(),this._scrollStrategy&&this._scrollStrategy.enable(),this._afterNextRenderRef?.destroy(),this._afterNextRenderRef=ne(()=>{this.hasAttached()&&this.updatePosition()},{injector:this._injector}),this._togglePointerEvents(!0),this._config.hasBackdrop&&this._attachBackdrop(),this._config.panelClass&&this._toggleClasses(this._pane,this._config.panelClass,!0),this._attachments.next(),this._completeDetachContent(),this._keyboardDispatcher.add(this),this._config.disposeOnNavigation&&(this._locationChanges=this._location.subscribe(()=>this.dispose())),this._outsideClickDispatcher.add(this),typeof e?.onDestroy=="function"&&e.onDestroy(()=>{this.hasAttached()&&this._ngZone.runOutsideAngular(()=>Promise.resolve().then(()=>this.detach()))}),e}detach(){if(!this.hasAttached())return;this.detachBackdrop(),this._togglePointerEvents(!1),this._positionStrategy&&this._positionStrategy.detach&&this._positionStrategy.detach(),this._scrollStrategy&&this._scrollStrategy.disable();let i=this._portalOutlet.detach();return this._detachments.next(),this._completeDetachContent(),this._keyboardDispatcher.remove(this),this._detachContentWhenEmpty(),this._locationChanges.unsubscribe(),this._outsideClickDispatcher.remove(this),i}dispose(){let i=this.hasAttached();this._positionStrategy&&this._positionStrategy.dispose(),this._disposeScrollStrategy(),this._backdropRef?.dispose(),this._locationChanges.unsubscribe(),this._keyboardDispatcher.remove(this),this._portalOutlet.dispose(),this._attachments.complete(),this._backdropClick.complete(),this._keydownEvents.complete(),this._outsidePointerEvents.complete(),this._outsideClickDispatcher.remove(this),this._host?.remove(),this._afterNextRenderRef?.destroy(),this._previousHostParent=this._pane=this._host=this._backdropRef=null,i&&this._detachments.next(),this._detachments.complete(),this._completeDetachContent()}hasAttached(){return this._portalOutlet.hasAttached()}backdropClick(){return this._backdropClick}attachments(){return this._attachments}detachments(){return this._detachments}keydownEvents(){return this._keydownEvents}outsidePointerEvents(){return this._outsidePointerEvents}getConfig(){return this._config}updatePosition(){this._positionStrategy&&this._positionStrategy.apply()}updatePositionStrategy(i){i!==this._positionStrategy&&(this._positionStrategy&&this._positionStrategy.dispose(),this._positionStrategy=i,this.hasAttached()&&(i.attach(this),this.updatePosition()))}updateSize(i){this._config=m(m({},this._config),i),this._updateElementSize()}setDirection(i){this._config=k(m({},this._config),{direction:i}),this._updateElementDirection()}addPanelClass(i){this._pane&&this._toggleClasses(this._pane,i,!0)}removePanelClass(i){this._pane&&this._toggleClasses(this._pane,i,!1)}getDirection(){let i=this._config.direction;return i?typeof i=="string"?i:i.value:"ltr"}updateScrollStrategy(i){i!==this._scrollStrategy&&(this._disposeScrollStrategy(),this._scrollStrategy=i,this.hasAttached()&&(i.attach(this),i.enable()))}_updateElementDirection(){this._host.setAttribute("dir",this.getDirection())}_updateElementSize(){if(!this._pane)return;let i=this._pane.style;i.width=P(this._config.width),i.height=P(this._config.height),i.minWidth=P(this._config.minWidth),i.minHeight=P(this._config.minHeight),i.maxWidth=P(this._config.maxWidth),i.maxHeight=P(this._config.maxHeight)}_togglePointerEvents(i){this._pane.style.pointerEvents=i?"":"none"}_attachBackdrop(){let i="cdk-overlay-backdrop-showing";this._backdropRef?.dispose(),this._backdropRef=new Pi(this._document,this._renderer,this._ngZone,e=>{this._backdropClick.next(e)}),this._animationsDisabled&&this._backdropRef.element.classList.add("cdk-overlay-backdrop-noop-animation"),this._config.backdropClass&&this._toggleClasses(this._backdropRef.element,this._config.backdropClass,!0),this._host.parentElement.insertBefore(this._backdropRef.element,this._host),!this._animationsDisabled&&typeof requestAnimationFrame<"u"?this._ngZone.runOutsideAngular(()=>{requestAnimationFrame(()=>this._backdropRef?.element.classList.add(i))}):this._backdropRef.element.classList.add(i)}_updateStackingOrder(){this._host.nextSibling&&this._host.parentNode.appendChild(this._host)}detachBackdrop(){this._animationsDisabled?(this._backdropRef?.dispose(),this._backdropRef=null):this._backdropRef?.detach()}_toggleClasses(i,e,t){let o=Lt(e||[]).filter(r=>!!r);o.length&&(t?i.classList.add(...o):i.classList.remove(...o))}_detachContentWhenEmpty(){let i=!1;try{this._detachContentAfterRenderRef=ne(()=>{i=!0,this._detachContent()},{injector:this._injector})}catch(e){if(i)throw e;this._detachContent()}globalThis.MutationObserver&&this._pane&&(this._detachContentMutationObserver||=new globalThis.MutationObserver(()=>{this._detachContent()}),this._detachContentMutationObserver.observe(this._pane,{childList:!0}))}_detachContent(){(!this._pane||!this._host||this._pane.children.length===0)&&(this._pane&&this._config.panelClass&&this._toggleClasses(this._pane,this._config.panelClass,!1),this._host&&this._host.parentElement&&(this._previousHostParent=this._host.parentElement,this._host.remove()),this._completeDetachContent())}_completeDetachContent(){this._detachContentAfterRenderRef?.destroy(),this._detachContentAfterRenderRef=void 0,this._detachContentMutationObserver?.disconnect()}_disposeScrollStrategy(){let i=this._scrollStrategy;i?.disable(),i?.detach?.()}},vo="cdk-overlay-connected-position-bounding-box",Fr=/([A-Za-z%]+)$/;function Fi(n,i){return new Jt(i,n.get(Oe),n.get(M),n.get(H),n.get(ii))}var Jt=class{_viewportRuler;_document;_platform;_overlayContainer;_overlayRef;_isInitialRender;_lastBoundingBoxSize={width:0,height:0};_isPushed=!1;_canPush=!0;_growAfterOpen=!1;_hasFlexibleDimensions=!0;_positionLocked=!1;_originRect;_overlayRect;_viewportRect;_containerRect;_viewportMargin=0;_scrollables=[];_preferredPositions=[];_origin;_pane;_isDisposed;_boundingBox;_lastPosition;_lastScrollVisibility;_positionChanges=new y;_resizeSubscription=K.EMPTY;_offsetX=0;_offsetY=0;_transformOriginSelector;_appliedPanelClasses=[];_previousPushAmount;positionChanges=this._positionChanges;get positions(){return this._preferredPositions}constructor(i,e,t,o,r){this._viewportRuler=e,this._document=t,this._platform=o,this._overlayContainer=r,this.setOrigin(i)}attach(i){this._overlayRef&&this._overlayRef,this._validatePositions(),i.hostElement.classList.add(vo),this._overlayRef=i,this._boundingBox=i.hostElement,this._pane=i.overlayElement,this._isDisposed=!1,this._isInitialRender=!0,this._lastPosition=null,this._resizeSubscription.unsubscribe(),this._resizeSubscription=this._viewportRuler.change().subscribe(()=>{this._isInitialRender=!0,this.apply()})}apply(){if(this._isDisposed||!this._platform.isBrowser)return;if(!this._isInitialRender&&this._positionLocked&&this._lastPosition){this.reapplyLastPosition();return}this._clearPanelClasses(),this._resetOverlayElementStyles(),this._resetBoundingBoxStyles(),this._viewportRect=this._getNarrowedViewportRect(),this._originRect=this._getOriginRect(),this._overlayRect=this._pane.getBoundingClientRect(),this._containerRect=this._overlayContainer.getContainerElement().getBoundingClientRect();let i=this._originRect,e=this._overlayRect,t=this._viewportRect,o=this._containerRect,r=[],s;for(let a of this._preferredPositions){let c=this._getOriginPoint(i,o,a),l=this._getOverlayPoint(c,e,a),d=this._getOverlayFit(l,e,t,a);if(d.isCompletelyWithinViewport){this._isPushed=!1,this._applyPosition(a,c);return}if(this._canFitWithFlexibleDimensions(d,l,t)){r.push({position:a,origin:c,overlayRect:e,boundingBoxRect:this._calculateBoundingBoxRect(c,a)});continue}(!s||s.overlayFit.visibleArea<d.visibleArea)&&(s={overlayFit:d,overlayPoint:l,originPoint:c,position:a,overlayRect:e})}if(r.length){let a=null,c=-1;for(let l of r){let d=l.boundingBoxRect.width*l.boundingBoxRect.height*(l.position.weight||1);d>c&&(c=d,a=l)}this._isPushed=!1,this._applyPosition(a.position,a.origin);return}if(this._canPush){this._isPushed=!0,this._applyPosition(s.position,s.originPoint);return}this._applyPosition(s.position,s.originPoint)}detach(){this._clearPanelClasses(),this._lastPosition=null,this._previousPushAmount=null,this._resizeSubscription.unsubscribe()}dispose(){this._isDisposed||(this._boundingBox&&Re(this._boundingBox.style,{top:"",left:"",right:"",bottom:"",height:"",width:"",alignItems:"",justifyContent:""}),this._pane&&this._resetOverlayElementStyles(),this._overlayRef&&this._overlayRef.hostElement.classList.remove(vo),this.detach(),this._positionChanges.complete(),this._overlayRef=this._boundingBox=null,this._isDisposed=!0)}reapplyLastPosition(){if(this._isDisposed||!this._platform.isBrowser)return;let i=this._lastPosition;if(i){this._originRect=this._getOriginRect(),this._overlayRect=this._pane.getBoundingClientRect(),this._viewportRect=this._getNarrowedViewportRect(),this._containerRect=this._overlayContainer.getContainerElement().getBoundingClientRect();let e=this._getOriginPoint(this._originRect,this._containerRect,i);this._applyPosition(i,e)}else this.apply()}withScrollableContainers(i){return this._scrollables=i,this}withPositions(i){return this._preferredPositions=i,i.indexOf(this._lastPosition)===-1&&(this._lastPosition=null),this._validatePositions(),this}withViewportMargin(i){return this._viewportMargin=i,this}withFlexibleDimensions(i=!0){return this._hasFlexibleDimensions=i,this}withGrowAfterOpen(i=!0){return this._growAfterOpen=i,this}withPush(i=!0){return this._canPush=i,this}withLockedPosition(i=!0){return this._positionLocked=i,this}setOrigin(i){return this._origin=i,this}withDefaultOffsetX(i){return this._offsetX=i,this}withDefaultOffsetY(i){return this._offsetY=i,this}withTransformOriginOn(i){return this._transformOriginSelector=i,this}_getOriginPoint(i,e,t){let o;if(t.originX=="center")o=i.left+i.width/2;else{let s=this._isRtl()?i.right:i.left,a=this._isRtl()?i.left:i.right;o=t.originX=="start"?s:a}e.left<0&&(o-=e.left);let r;return t.originY=="center"?r=i.top+i.height/2:r=t.originY=="top"?i.top:i.bottom,e.top<0&&(r-=e.top),{x:o,y:r}}_getOverlayPoint(i,e,t){let o;t.overlayX=="center"?o=-e.width/2:t.overlayX==="start"?o=this._isRtl()?-e.width:0:o=this._isRtl()?0:-e.width;let r;return t.overlayY=="center"?r=-e.height/2:r=t.overlayY=="top"?0:-e.height,{x:i.x+o,y:i.y+r}}_getOverlayFit(i,e,t,o){let r=Co(e),{x:s,y:a}=i,c=this._getOffset(o,"x"),l=this._getOffset(o,"y");c&&(s+=c),l&&(a+=l);let d=0-s,u=s+r.width-t.width,p=0-a,f=a+r.height-t.height,g=this._subtractOverflows(r.width,d,u),C=this._subtractOverflows(r.height,p,f),V=g*C;return{visibleArea:V,isCompletelyWithinViewport:r.width*r.height===V,fitsInViewportVertically:C===r.height,fitsInViewportHorizontally:g==r.width}}_canFitWithFlexibleDimensions(i,e,t){if(this._hasFlexibleDimensions){let o=t.bottom-e.y,r=t.right-e.x,s=yo(this._overlayRef.getConfig().minHeight),a=yo(this._overlayRef.getConfig().minWidth),c=i.fitsInViewportVertically||s!=null&&s<=o,l=i.fitsInViewportHorizontally||a!=null&&a<=r;return c&&l}return!1}_pushOverlayOnScreen(i,e,t){if(this._previousPushAmount&&this._positionLocked)return{x:i.x+this._previousPushAmount.x,y:i.y+this._previousPushAmount.y};let o=Co(e),r=this._viewportRect,s=Math.max(i.x+o.width-r.width,0),a=Math.max(i.y+o.height-r.height,0),c=Math.max(r.top-t.top-i.y,0),l=Math.max(r.left-t.left-i.x,0),d=0,u=0;return o.width<=r.width?d=l||-s:d=i.x<this._viewportMargin?r.left-t.left-i.x:0,o.height<=r.height?u=c||-a:u=i.y<this._viewportMargin?r.top-t.top-i.y:0,this._previousPushAmount={x:d,y:u},{x:i.x+d,y:i.y+u}}_applyPosition(i,e){if(this._setTransformOrigin(i),this._setOverlayElementStyles(e,i),this._setBoundingBoxStyles(e,i),i.panelClass&&this._addPanelClasses(i.panelClass),this._positionChanges.observers.length){let t=this._getScrollVisibility();if(i!==this._lastPosition||!this._lastScrollVisibility||!Ur(this._lastScrollVisibility,t)){let o=new qt(i,t);this._positionChanges.next(o)}this._lastScrollVisibility=t}this._lastPosition=i,this._isInitialRender=!1}_setTransformOrigin(i){if(!this._transformOriginSelector)return;let e=this._boundingBox.querySelectorAll(this._transformOriginSelector),t,o=i.overlayY;i.overlayX==="center"?t="center":this._isRtl()?t=i.overlayX==="start"?"right":"left":t=i.overlayX==="start"?"left":"right";for(let r=0;r<e.length;r++)e[r].style.transformOrigin=`${t} ${o}`}_calculateBoundingBoxRect(i,e){let t=this._viewportRect,o=this._isRtl(),r,s,a;if(e.overlayY==="top")s=i.y,r=t.height-s+this._viewportMargin;else if(e.overlayY==="bottom")a=t.height-i.y+this._viewportMargin*2,r=t.height-a+this._viewportMargin;else{let f=Math.min(t.bottom-i.y+t.top,i.y),g=this._lastBoundingBoxSize.height;r=f*2,s=i.y-f,r>g&&!this._isInitialRender&&!this._growAfterOpen&&(s=i.y-g/2)}let c=e.overlayX==="start"&&!o||e.overlayX==="end"&&o,l=e.overlayX==="end"&&!o||e.overlayX==="start"&&o,d,u,p;if(l)p=t.width-i.x+this._viewportMargin*2,d=i.x-this._viewportMargin;else if(c)u=i.x,d=t.right-i.x;else{let f=Math.min(t.right-i.x+t.left,i.x),g=this._lastBoundingBoxSize.width;d=f*2,u=i.x-f,d>g&&!this._isInitialRender&&!this._growAfterOpen&&(u=i.x-g/2)}return{top:s,left:u,bottom:a,right:p,width:d,height:r}}_setBoundingBoxStyles(i,e){let t=this._calculateBoundingBoxRect(i,e);!this._isInitialRender&&!this._growAfterOpen&&(t.height=Math.min(t.height,this._lastBoundingBoxSize.height),t.width=Math.min(t.width,this._lastBoundingBoxSize.width));let o={};if(this._hasExactPosition())o.top=o.left="0",o.bottom=o.right=o.maxHeight=o.maxWidth="",o.width=o.height="100%";else{let r=this._overlayRef.getConfig().maxHeight,s=this._overlayRef.getConfig().maxWidth;o.height=P(t.height),o.top=P(t.top),o.bottom=P(t.bottom),o.width=P(t.width),o.left=P(t.left),o.right=P(t.right),e.overlayX==="center"?o.alignItems="center":o.alignItems=e.overlayX==="end"?"flex-end":"flex-start",e.overlayY==="center"?o.justifyContent="center":o.justifyContent=e.overlayY==="bottom"?"flex-end":"flex-start",r&&(o.maxHeight=P(r)),s&&(o.maxWidth=P(s))}this._lastBoundingBoxSize=t,Re(this._boundingBox.style,o)}_resetBoundingBoxStyles(){Re(this._boundingBox.style,{top:"0",left:"0",right:"0",bottom:"0",height:"",width:"",alignItems:"",justifyContent:""})}_resetOverlayElementStyles(){Re(this._pane.style,{top:"",left:"",bottom:"",right:"",position:"",transform:""})}_setOverlayElementStyles(i,e){let t={},o=this._hasExactPosition(),r=this._hasFlexibleDimensions,s=this._overlayRef.getConfig();if(o){let d=this._viewportRuler.getViewportScrollPosition();Re(t,this._getExactOverlayY(e,i,d)),Re(t,this._getExactOverlayX(e,i,d))}else t.position="static";let a="",c=this._getOffset(e,"x"),l=this._getOffset(e,"y");c&&(a+=`translateX(${c}px) `),l&&(a+=`translateY(${l}px)`),t.transform=a.trim(),s.maxHeight&&(o?t.maxHeight=P(s.maxHeight):r&&(t.maxHeight="")),s.maxWidth&&(o?t.maxWidth=P(s.maxWidth):r&&(t.maxWidth="")),Re(this._pane.style,t)}_getExactOverlayY(i,e,t){let o={top:"",bottom:""},r=this._getOverlayPoint(e,this._overlayRect,i);if(this._isPushed&&(r=this._pushOverlayOnScreen(r,this._overlayRect,t)),i.overlayY==="bottom"){let s=this._document.documentElement.clientHeight;o.bottom=`${s-(r.y+this._overlayRect.height)}px`}else o.top=P(r.y);return o}_getExactOverlayX(i,e,t){let o={left:"",right:""},r=this._getOverlayPoint(e,this._overlayRect,i);this._isPushed&&(r=this._pushOverlayOnScreen(r,this._overlayRect,t));let s;if(this._isRtl()?s=i.overlayX==="end"?"left":"right":s=i.overlayX==="end"?"right":"left",s==="right"){let a=this._document.documentElement.clientWidth;o.right=`${a-(r.x+this._overlayRect.width)}px`}else o.left=P(r.x);return o}_getScrollVisibility(){let i=this._getOriginRect(),e=this._pane.getBoundingClientRect(),t=this._scrollables.map(o=>o.getElementRef().nativeElement.getBoundingClientRect());return{isOriginClipped:mo(i,t),isOriginOutsideView:Ti(i,t),isOverlayClipped:mo(e,t),isOverlayOutsideView:Ti(e,t)}}_subtractOverflows(i,...e){return e.reduce((t,o)=>t-Math.max(o,0),i)}_getNarrowedViewportRect(){let i=this._document.documentElement.clientWidth,e=this._document.documentElement.clientHeight,t=this._viewportRuler.getViewportScrollPosition();return{top:t.top+this._viewportMargin,left:t.left+this._viewportMargin,right:t.left+i-this._viewportMargin,bottom:t.top+e-this._viewportMargin,width:i-2*this._viewportMargin,height:e-2*this._viewportMargin}}_isRtl(){return this._overlayRef.getDirection()==="rtl"}_hasExactPosition(){return!this._hasFlexibleDimensions||this._isPushed}_getOffset(i,e){return e==="x"?i.offsetX==null?this._offsetX:i.offsetX:i.offsetY==null?this._offsetY:i.offsetY}_validatePositions(){}_addPanelClasses(i){this._pane&&Lt(i).forEach(e=>{e!==""&&this._appliedPanelClasses.indexOf(e)===-1&&(this._appliedPanelClasses.push(e),this._pane.classList.add(e))})}_clearPanelClasses(){this._pane&&(this._appliedPanelClasses.forEach(i=>{this._pane.classList.remove(i)}),this._appliedPanelClasses=[])}_getOriginRect(){let i=this._origin;if(i instanceof R)return i.nativeElement.getBoundingClientRect();if(i instanceof Element)return i.getBoundingClientRect();let e=i.width||0,t=i.height||0;return{top:i.y,bottom:i.y+t,left:i.x,right:i.x+e,height:t,width:e}}};function Re(n,i){for(let e in i)i.hasOwnProperty(e)&&(n[e]=i[e]);return n}function yo(n){if(typeof n!="number"&&n!=null){let[i,e]=n.split(Fr);return!e||e==="px"?parseFloat(i):null}return n||null}function Co(n){return{top:Math.floor(n.top),right:Math.floor(n.right),bottom:Math.floor(n.bottom),left:Math.floor(n.left),width:Math.floor(n.width),height:Math.floor(n.height)}}function Ur(n,i){return n===i?!0:n.isOriginClipped===i.isOriginClipped&&n.isOriginOutsideView===i.isOriginOutsideView&&n.isOverlayClipped===i.isOverlayClipped&&n.isOverlayOutsideView===i.isOverlayOutsideView}var bo="cdk-global-overlay-wrapper";function Ze(n){return new ei}var ei=class{_overlayRef;_cssPosition="static";_topOffset="";_bottomOffset="";_alignItems="";_xPosition="";_xOffset="";_width="";_height="";_isDisposed=!1;attach(i){let e=i.getConfig();this._overlayRef=i,this._width&&!e.width&&i.updateSize({width:this._width}),this._height&&!e.height&&i.updateSize({height:this._height}),i.hostElement.classList.add(bo),this._isDisposed=!1}top(i=""){return this._bottomOffset="",this._topOffset=i,this._alignItems="flex-start",this}left(i=""){return this._xOffset=i,this._xPosition="left",this}bottom(i=""){return this._topOffset="",this._bottomOffset=i,this._alignItems="flex-end",this}right(i=""){return this._xOffset=i,this._xPosition="right",this}start(i=""){return this._xOffset=i,this._xPosition="start",this}end(i=""){return this._xOffset=i,this._xPosition="end",this}width(i=""){return this._overlayRef?this._overlayRef.updateSize({width:i}):this._width=i,this}height(i=""){return this._overlayRef?this._overlayRef.updateSize({height:i}):this._height=i,this}centerHorizontally(i=""){return this.left(i),this._xPosition="center",this}centerVertically(i=""){return this.top(i),this._alignItems="center",this}apply(){if(!this._overlayRef||!this._overlayRef.hasAttached())return;let i=this._overlayRef.overlayElement.style,e=this._overlayRef.hostElement.style,t=this._overlayRef.getConfig(),{width:o,height:r,maxWidth:s,maxHeight:a}=t,c=(o==="100%"||o==="100vw")&&(!s||s==="100%"||s==="100vw"),l=(r==="100%"||r==="100vh")&&(!a||a==="100%"||a==="100vh"),d=this._xPosition,u=this._xOffset,p=this._overlayRef.getConfig().direction==="rtl",f="",g="",C="";c?C="flex-start":d==="center"?(C="center",p?g=u:f=u):p?d==="left"||d==="end"?(C="flex-end",f=u):(d==="right"||d==="start")&&(C="flex-start",g=u):d==="left"||d==="start"?(C="flex-start",f=u):(d==="right"||d==="end")&&(C="flex-end",g=u),i.position=this._cssPosition,i.marginLeft=c?"0":f,i.marginTop=l?"0":this._topOffset,i.marginBottom=this._bottomOffset,i.marginRight=c?"0":g,e.justifyContent=C,e.alignItems=l?"flex-start":this._alignItems}dispose(){if(this._isDisposed||!this._overlayRef)return;let i=this._overlayRef.overlayElement.style,e=this._overlayRef.hostElement,t=e.style;e.classList.remove(bo),t.justifyContent=t.alignItems=i.marginTop=i.marginBottom=i.marginLeft=i.marginRight=i.position="",this._overlayRef=null,this._isDisposed=!0}},Ao=(()=>{class n{_injector=h(O);constructor(){}global(){return Ze()}flexibleConnectedTo(e){return Fi(this._injector,e)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function pt(n,i){n.get(Ye).load(wo);let e=n.get(ii),t=n.get(M),o=n.get(pe),r=n.get(Ne),s=n.get(ae),a=t.createElement("div"),c=t.createElement("div");c.id=o.getId("cdk-overlay-"),c.classList.add("cdk-overlay-pane"),a.appendChild(c),e.getContainerElement().appendChild(a);let l=new Wt(c,r,n),d=new ke(i),u=n.get(Fe,null,{optional:!0})||n.get(oe).createRenderer(null,null);return d.direction=d.direction||s.value,new Ke(l,a,c,d,n.get(U),n.get(Eo),t,n.get(Vn),n.get(Oo),i?.disableAnimations??n.get(Rt,null,{optional:!0})==="NoopAnimations",n.get(Me),u)}var Ro=(()=>{class n{scrollStrategies=h(Io);_positionBuilder=h(Ao);_injector=h(O);constructor(){}create(e){return pt(this._injector,e)}position(){return this._positionBuilder}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),Nr=[{originX:"start",originY:"bottom",overlayX:"start",overlayY:"top"},{originX:"start",originY:"top",overlayX:"start",overlayY:"bottom"},{originX:"end",originY:"top",overlayX:"end",overlayY:"bottom"},{originX:"end",originY:"bottom",overlayX:"end",overlayY:"top"}],ko=new A("cdk-connected-overlay-scroll-strategy",{providedIn:"root",factory:()=>{let n=h(O);return()=>ti(n)}}),Mi=(()=>{class n{elementRef=h(R);constructor(){}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,selectors:[["","cdk-overlay-origin",""],["","overlay-origin",""],["","cdkOverlayOrigin",""]],exportAs:["cdkOverlayOrigin"]})}return n})(),zr=(()=>{class n{_dir=h(ae,{optional:!0});_injector=h(O);_overlayRef;_templatePortal;_backdropSubscription=K.EMPTY;_attachSubscription=K.EMPTY;_detachSubscription=K.EMPTY;_positionSubscription=K.EMPTY;_offsetX;_offsetY;_position;_scrollStrategyFactory=h(ko);_disposeOnNavigation=!1;_ngZone=h(U);origin;positions;positionStrategy;get offsetX(){return this._offsetX}set offsetX(e){this._offsetX=e,this._position&&this._updatePositionStrategy(this._position)}get offsetY(){return this._offsetY}set offsetY(e){this._offsetY=e,this._position&&this._updatePositionStrategy(this._position)}width;height;minWidth;minHeight;backdropClass;panelClass;viewportMargin=0;scrollStrategy;open=!1;disableClose=!1;transformOriginSelector;hasBackdrop=!1;lockPosition=!1;flexibleDimensions=!1;growAfterOpen=!1;push=!1;get disposeOnNavigation(){return this._disposeOnNavigation}set disposeOnNavigation(e){this._disposeOnNavigation=e}backdropClick=new B;positionChange=new B;attach=new B;detach=new B;overlayKeydown=new B;overlayOutsideClick=new B;constructor(){let e=h(be),t=h(Ue);this._templatePortal=new we(e,t),this.scrollStrategy=this._scrollStrategyFactory()}get overlayRef(){return this._overlayRef}get dir(){return this._dir?this._dir.value:"ltr"}ngOnDestroy(){this._attachSubscription.unsubscribe(),this._detachSubscription.unsubscribe(),this._backdropSubscription.unsubscribe(),this._positionSubscription.unsubscribe(),this._overlayRef?.dispose()}ngOnChanges(e){this._position&&(this._updatePositionStrategy(this._position),this._overlayRef?.updateSize({width:this.width,minWidth:this.minWidth,height:this.height,minHeight:this.minHeight}),e.origin&&this.open&&this._position.apply()),e.open&&(this.open?this.attachOverlay():this.detachOverlay())}_createOverlay(){(!this.positions||!this.positions.length)&&(this.positions=Nr);let e=this._overlayRef=pt(this._injector,this._buildConfig());this._attachSubscription=e.attachments().subscribe(()=>this.attach.emit()),this._detachSubscription=e.detachments().subscribe(()=>this.detach.emit()),e.keydownEvents().subscribe(t=>{this.overlayKeydown.next(t),t.keyCode===27&&!this.disableClose&&!ge(t)&&(t.preventDefault(),this.detachOverlay())}),this._overlayRef.outsidePointerEvents().subscribe(t=>{let o=this._getOriginElement(),r=ee(t);(!o||o!==r&&!o.contains(r))&&this.overlayOutsideClick.next(t)})}_buildConfig(){let e=this._position=this.positionStrategy||this._createPositionStrategy(),t=new ke({direction:this._dir||"ltr",positionStrategy:e,scrollStrategy:this.scrollStrategy,hasBackdrop:this.hasBackdrop,disposeOnNavigation:this.disposeOnNavigation});return(this.width||this.width===0)&&(t.width=this.width),(this.height||this.height===0)&&(t.height=this.height),(this.minWidth||this.minWidth===0)&&(t.minWidth=this.minWidth),(this.minHeight||this.minHeight===0)&&(t.minHeight=this.minHeight),this.backdropClass&&(t.backdropClass=this.backdropClass),this.panelClass&&(t.panelClass=this.panelClass),t}_updatePositionStrategy(e){let t=this.positions.map(o=>({originX:o.originX,originY:o.originY,overlayX:o.overlayX,overlayY:o.overlayY,offsetX:o.offsetX||this.offsetX,offsetY:o.offsetY||this.offsetY,panelClass:o.panelClass||void 0}));return e.setOrigin(this._getOrigin()).withPositions(t).withFlexibleDimensions(this.flexibleDimensions).withPush(this.push).withGrowAfterOpen(this.growAfterOpen).withViewportMargin(this.viewportMargin).withLockedPosition(this.lockPosition).withTransformOriginOn(this.transformOriginSelector)}_createPositionStrategy(){let e=Fi(this._injector,this._getOrigin());return this._updatePositionStrategy(e),e}_getOrigin(){return this.origin instanceof Mi?this.origin.elementRef:this.origin}_getOriginElement(){return this.origin instanceof Mi?this.origin.elementRef.nativeElement:this.origin instanceof R?this.origin.nativeElement:typeof Element<"u"&&this.origin instanceof Element?this.origin:null}attachOverlay(){this._overlayRef?this._overlayRef.getConfig().hasBackdrop=this.hasBackdrop:this._createOverlay(),this._overlayRef.hasAttached()||this._overlayRef.attach(this._templatePortal),this.hasBackdrop?this._backdropSubscription=this._overlayRef.backdropClick().subscribe(e=>{this.backdropClick.emit(e)}):this._backdropSubscription.unsubscribe(),this._positionSubscription.unsubscribe(),this.positionChange.observers.length>0&&(this._positionSubscription=this._position.positionChanges.pipe(Sn(()=>this.positionChange.observers.length>0)).subscribe(e=>{this._ngZone.run(()=>this.positionChange.emit(e)),this.positionChange.observers.length===0&&this._positionSubscription.unsubscribe()})),this.open=!0}detachOverlay(){this._overlayRef?.detach(),this._backdropSubscription.unsubscribe(),this._positionSubscription.unsubscribe(),this.open=!1}static \u0275fac=function(t){return new(t||n)};static \u0275dir=L({type:n,selectors:[["","cdk-connected-overlay",""],["","connected-overlay",""],["","cdkConnectedOverlay",""]],inputs:{origin:[0,"cdkConnectedOverlayOrigin","origin"],positions:[0,"cdkConnectedOverlayPositions","positions"],positionStrategy:[0,"cdkConnectedOverlayPositionStrategy","positionStrategy"],offsetX:[0,"cdkConnectedOverlayOffsetX","offsetX"],offsetY:[0,"cdkConnectedOverlayOffsetY","offsetY"],width:[0,"cdkConnectedOverlayWidth","width"],height:[0,"cdkConnectedOverlayHeight","height"],minWidth:[0,"cdkConnectedOverlayMinWidth","minWidth"],minHeight:[0,"cdkConnectedOverlayMinHeight","minHeight"],backdropClass:[0,"cdkConnectedOverlayBackdropClass","backdropClass"],panelClass:[0,"cdkConnectedOverlayPanelClass","panelClass"],viewportMargin:[0,"cdkConnectedOverlayViewportMargin","viewportMargin"],scrollStrategy:[0,"cdkConnectedOverlayScrollStrategy","scrollStrategy"],open:[0,"cdkConnectedOverlayOpen","open"],disableClose:[0,"cdkConnectedOverlayDisableClose","disableClose"],transformOriginSelector:[0,"cdkConnectedOverlayTransformOriginOn","transformOriginSelector"],hasBackdrop:[2,"cdkConnectedOverlayHasBackdrop","hasBackdrop",q],lockPosition:[2,"cdkConnectedOverlayLockPosition","lockPosition",q],flexibleDimensions:[2,"cdkConnectedOverlayFlexibleDimensions","flexibleDimensions",q],growAfterOpen:[2,"cdkConnectedOverlayGrowAfterOpen","growAfterOpen",q],push:[2,"cdkConnectedOverlayPush","push",q],disposeOnNavigation:[2,"cdkConnectedOverlayDisposeOnNavigation","disposeOnNavigation",q]},outputs:{backdropClick:"backdropClick",positionChange:"positionChange",attach:"attach",detach:"detach",overlayKeydown:"overlayKeydown",overlayOutsideClick:"overlayOutsideClick"},exportAs:["cdkConnectedOverlay"],features:[ie]})}return n})();function Br(n){let i=h(O);return()=>ti(i)}var $r={provide:ko,useFactory:Br},gt=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=N({type:n});static \u0275inj=F({providers:[Ro,$r],imports:[fe,Ae,Oi,Oi]})}return n})();var Vr=new Set(["annotation-id","class","style","id","slot","title","hidden","dark","role","tabindex","ng-reflect-annotation-id","ng-version","_nghost","_ngcontent"]),Ui="__veltContext";function jr(n){let i={};try{if(!n?.attributes)return i;let e=n.attributes;for(let t=0;t<e.length;t++){let o=e[t].name.toLowerCase();Vr.has(o)||o.startsWith("_ng")||o.startsWith("ng-")||o.startsWith("data-")||o.startsWith("aria-")||o!=="velt-element"&&(i[o]=e[t].value)}}catch{}return i}function Hr(n,i){return m(m({},n||{}),i||{})}function To(n){try{let i=n?.[Ui];return i&&typeof i=="object"?i:void 0}catch{return}}var Ni=null,zi=null,Bi,$i=!1;function Te(){Ni=null,zi=null,Bi=void 0,$i=!1}function Gr(n,i){try{if(!n){Te();return}Ni=n,zi=n.parentElement,Bi=i,$i=!0}catch{Te()}}function bc(n){try{if(!n||!$i||Ni!==n)return;if(zi!==n.parentElement){Te();return}let i=Bi;return Te(),{payload:i}}catch{return}}function xo(n){try{let i=n||null;for(;i;){let e=i.parentElement;if(!e){let o=i.getRootNode?.();if(o instanceof ShadowRoot&&o.host){i=o.host;continue}break}let t=To(e);if(t)return{host:e,payload:t};i=e}}catch{}}function Wr(n){try{return n?!!n.annotationId||Object.keys(n.contextData||{}).length>0||n.data!==void 0||n.localUIState!==void 0||n.registry!==void 0:!1}catch{return!1}}function Sc(n,i){try{if(!n)return;if(Te(),!Wr(i)){Yr(n,i.ownerRef);return}return n[Ui]=i,i}catch{return}}function Yr(n,i){try{if(!n)return;Te();let e=To(n);if(e&&e.ownerRef!==i)return;n[Ui]=void 0}catch{}}function Ic(n){let{host:i,inherited:e,ownAnnotationId:t,ownData:o,registry:r,ownLocalUIState:s,ownerRef:a}=n,c=jr(i),l=Hr(e?.contextData,c),d;try{d=i?.getAttribute?.("annotation-id")||void 0}catch{}return{annotationId:t||d||e?.annotationId,contextData:l,data:o??e?.data,registry:r??e?.registry,localUIState:s??e?.localUIState,ownerRef:a}}function Kr(n){try{let i=xo(n);return Gr(n,i?.payload),i?.payload?.localUIState}catch{return}}function Dc(n){try{if(n.isRoot||n.fromExplicitInput)return!1;let i=Kr(n.host);if(!i||i===n.current)return!1;if(n.isOwner)try{n.current?.update?.(e=>m({},e))}catch{}return n.adopt(i),!0}catch{return!1}}function Ec(n){try{return xo(n)?.payload?.data}catch{return}}var ni="__veltRefreshContext",Qe=new Set;function Oc(n,i,e){try{if(!n||typeof e!="function")return;n[ni]={ownerRef:i,fn:e},Qe.add(n)}catch{}}function oi(n){try{let i=n?.[ni];return i&&typeof i.fn=="function"?i.fn:void 0}catch{return}}function wc(n,i){try{if(!n)return;let e=n[ni];if(e&&e.ownerRef!==i)return;n[ni]=void 0,Qe.delete(n)}catch{}}var Xr=64;function Zr(n){let i=[];return Qe.forEach(e=>{if(!oi(e)){Qe.delete(e);return}n.contains(e)&&i.push(e)}),i.length>1&&i.sort((e,t)=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),i}function Qr(n){let i=[];return oi(n)&&i.push(n),n.querySelectorAll("*").forEach(e=>{oi(e)&&i.push(e)}),i}function Po(n){try{if(!n||n.nodeType!==Node.ELEMENT_NODE||(Te(),!Qe.size))return;let i=n;(Qe.size<=Xr?Zr(i):Qr(i)).forEach(t=>{let o=oi(t);try{o?.()}catch{}})}catch{}}var Mo="__veltHandled",Lo="velt",qe=new WeakSet,ri=0;function Fo(n){try{if(!n||qe.has(n))return;qe.add(n),ri++}catch{}}function si(n){try{if(!n||!qe.has(n))return;qe.delete(n),ri=Math.max(0,ri-1)}catch{}}function qr(n){try{if(!n||ri===0)return!1;let i=typeof n.composedPath=="function"?n.composedPath():null;if(i){for(let t of i)if(qe.has(t))return!0;return!1}let e=n.target;for(;e;){if(qe.has(e))return!0;e=e.parentNode}return!1}catch{return!1}}function Uo(n){try{if(!n||(n[Mo]=Lo,qr(n)))return;n.stopPropagation()}catch{}}function No(n){try{return n?n[Mo]===Lo:!1}catch{return!1}}var ce=new WeakMap,Hi=new WeakSet,Jr=new Set(["snippyly-user-request-tool","snippyly-sidebar-button","velt-sidebar-button","velt-comments-sidebar-button","snippyly-comment-tool","velt-comment-tool","snippyly-area-tool","velt-area-tool","snippyly-tags-tool","velt-tags-tool","velt-autocomplete-tool"]),es=new WeakSet;function Pc(n){try{return!!n}catch{return!1}}function Bo(n){try{return!!n&&Jr.has(n.tagName.toLowerCase())}catch{return!1}}function ts(n){try{return!!n&&n.nodeType===Node.ELEMENT_NODE}catch{return!1}}function Mc(n){try{if(!n)return;if(Hi.has(n))return ce.get(n);if(Hi.add(n),Bo(n)){es.add(n);return}let i=Array.from(n.childNodes).filter(ts);if(!i.length)return;let e={host:n,nodes:i,claimed:!1};return ce.set(n,e),e}catch{return}}function Lc(n){try{if(!n)return;!n.claimed&&n.nodes.some(e=>!!e.parentNode)&&ce.delete(n.host)}catch{}}var Vi=null,mt=[];function is(){try{for(let n=mt.length-1;n>=0;n--){let i=mt[n];i.host.isConnected||(i.nodes.forEach(e=>{try{e.parentNode?.hasAttribute?.("data-velt-children-park")&&e.parentNode.removeChild(e)}catch{}}),mt.splice(n,1))}}catch{}}function ns(){try{if(Vi?.isConnected)return Vi;let n=document.createElement("div");return n.setAttribute("data-velt-children-park","true"),n.style.display="none",document.body.appendChild(n),Vi=n,n}catch{return null}}function Fc(n){try{if(!n)return;let i=ce.get(n);if(!i||i.claimed||!i.nodes.some(o=>rs(o,r=>r.startsWith("velt-")||r.startsWith("snippyly-"))))return;let t=ns();if(!t)return;is(),i.nodes.forEach(o=>{try{o.parentNode!==t&&t.appendChild(o)}catch{}}),mt.some(o=>o.host===n)||mt.push({host:n,nodes:i.nodes})}catch{}}function Uc(n){try{if(!n)return;let i=ce.get(n);if(!i||i.claimed)return;console.warn(`[Velt] <${n.tagName.toLowerCase()}> is not rendering the markup you placed inside it. Either this primitive has no children slot, or its visibility condition is currently false \u2014 in which case your markup is being held and will render as soon as the condition becomes true. If it should render regardless, set default-condition="false".`)}catch{}}function Nc(n){try{if(!n||Hi.has(n)||ce.has(n)||Bo(n)||!Array.from(n.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&!!(e.textContent||"").trim()))return;console.warn(`[Velt] <${n.tagName.toLowerCase()}> was given plain text as its content, which is not supported. Wrap it in an element \u2014 for example <span>your text</span>.`)}catch{}}function zc(n){try{if(!n)return!1;let i=ce.get(n);return!!i&&i.nodes.length>0}catch{return!1}}function Bc(n){try{let i=!!n.wireframeTemplate||!!n.hasCustomerChildren;return!i&&!!n.shadowDom||i&&!!n.isExplicitShadowDom}catch{return!1}}function $c(n,i){try{if(!n)return;let e=ce.get(n);return!e||!e.nodes.length||e.claimed&&e.owner!==i?void 0:e}catch{return}}function os(n,i,e){try{if(!n)return;let t=ce.get(n);if(!t)return;let o=i.toLowerCase(),r=t.nodes.findIndex(a=>a.tagName.toLowerCase()===o);if(r===-1)return;let[s]=t.nodes.splice(r,1);return t.nodes.length||(t.claimed=!0,t.owner=e),s}catch{return}}var zo=class{constructor(i){this.triggerTagName=i}get isActive(){return!!this.element}take(i,e){try{return this.element&&si(this.element),this.element=os(i,this.triggerTagName,e),!!this.element}catch{return!1}}place(i){try{return!this.element||!i?.parentNode?!1:(i.parentNode.insertBefore(this.element,i.nextSibling),Fo(this.element),Po(this.element),!0)}catch{return!1}}release(i){try{this.element&&si(this.element),this.element&&i&&this.element.parentNode!==i&&i.appendChild(this.element),this.element=void 0}catch{}}},ji="data-velt-hidden",ai=new WeakMap;function $o(n,i){try{if(n.getAttribute(ji)==="true"===i)return;if(i)ai.has(n)||ai.set(n,n.style.display||""),n.setAttribute(ji,"true"),n.style.display="none";else{n.removeAttribute(ji);let t=ai.get(n);t?n.style.display=t:n.style.removeProperty("display"),ai.delete(n)}}catch{}}function Vc(n,i){try{return n?(n.claimed=!0,n.owner=i,$o(n.host,!1),n.nodes):[]}catch{return[]}}function jc(n,i){try{if(!n||n.owner!==i)return;n.claimed=!1,n.owner=void 0,$o(n.host,!0),n.nodes.forEach(e=>{si(e);try{e.parentNode!==n.host&&n.host.appendChild(e)}catch{}})}catch{}}function rs(n,i){try{if(i(n.tagName.toLowerCase()))return!0;let e=n.querySelectorAll("*");for(let t=0;t<e.length;t++)if(i(e[t].tagName.toLowerCase()))return!0;return!1}catch{return!1}}function Gi(n){return n.buttons===0||n.detail===0}function Wi(n){let i=n.touches&&n.touches[0]||n.changedTouches&&n.changedTouches[0];return!!i&&i.identifier===-1&&(i.radiusX==null||i.radiusX===1)&&(i.radiusY==null||i.radiusY===1)}var _t;function ss(){if(_t==null&&typeof window<"u")try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:()=>_t=!0}))}finally{_t=_t||!1}return _t}function Vo(n){return ss()?n:!!n.capture}var jo=new A("cdk-input-modality-detector-options"),Ho={ignoreKeys:[18,17,224,91,16]},Go=650,Yi={passive:!0,capture:!0},Wo=(()=>{class n{_platform=h(H);_listenerCleanups;modalityDetected;modalityChanged;get mostRecentModality(){return this._modality.value}_mostRecentTarget=null;_modality=new I(null);_options;_lastTouchMs=0;_onKeydown=e=>{this._options?.ignoreKeys?.some(t=>t===e.keyCode)||(this._modality.next("keyboard"),this._mostRecentTarget=ee(e))};_onMousedown=e=>{Date.now()-this._lastTouchMs<Go||(this._modality.next(Gi(e)?"keyboard":"mouse"),this._mostRecentTarget=ee(e))};_onTouchstart=e=>{if(Wi(e)){this._modality.next("keyboard");return}this._lastTouchMs=Date.now(),this._modality.next("touch"),this._mostRecentTarget=ee(e)};constructor(){let e=h(U),t=h(M),o=h(jo,{optional:!0});if(this._options=m(m({},Ho),o),this.modalityDetected=this._modality.pipe(bn(1)),this.modalityChanged=this.modalityDetected.pipe(X()),this._platform.isBrowser){let r=h(oe).createRenderer(null,null);this._listenerCleanups=e.runOutsideAngular(()=>[r.listen(t,"keydown",this._onKeydown,Yi),r.listen(t,"mousedown",this._onMousedown,Yi),r.listen(t,"touchstart",this._onTouchstart,Yi)])}}ngOnDestroy(){this._modality.complete(),this._listenerCleanups?.forEach(e=>e())}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),vt=(function(n){return n[n.IMMEDIATE=0]="IMMEDIATE",n[n.EVENTUAL=1]="EVENTUAL",n})(vt||{}),Yo=new A("cdk-focus-monitor-default-options"),ci=Vo({passive:!0,capture:!0}),Ki=(()=>{class n{_ngZone=h(U);_platform=h(H);_inputModalityDetector=h(Wo);_origin=null;_lastFocusOrigin;_windowFocused=!1;_windowFocusTimeoutId;_originTimeoutId;_originFromTouchInteraction=!1;_elementInfo=new Map;_monitoredElementCount=0;_rootNodeFocusListenerCount=new Map;_detectionMode;_windowFocusListener=()=>{this._windowFocused=!0,this._windowFocusTimeoutId=setTimeout(()=>this._windowFocused=!1)};_document=h(M);_stopInputModalityDetector=new y;constructor(){let e=h(Yo,{optional:!0});this._detectionMode=e?.detectionMode||vt.IMMEDIATE}_rootNodeFocusAndBlurListener=e=>{let t=ee(e);for(let o=t;o;o=o.parentElement)e.type==="focus"?this._onFocus(e,o):this._onBlur(e,o)};monitor(e,t=!1){let o=De(e);if(!this._platform.isBrowser||o.nodeType!==1)return _();let r=po(o)||this._document,s=this._elementInfo.get(o);if(s)return t&&(s.checkChildren=!0),s.subject;let a={checkChildren:t,subject:new y,rootNode:r};return this._elementInfo.set(o,a),this._registerGlobalListeners(a),a.subject}stopMonitoring(e){let t=De(e),o=this._elementInfo.get(t);o&&(o.subject.complete(),this._setClasses(t),this._elementInfo.delete(t),this._removeGlobalListeners(o))}focusVia(e,t,o){let r=De(e),s=this._document.activeElement;r===s?this._getClosestElementsInfo(r).forEach(([a,c])=>this._originChanged(a,t,c)):(this._setOrigin(t),typeof r.focus=="function"&&r.focus(o))}ngOnDestroy(){this._elementInfo.forEach((e,t)=>this.stopMonitoring(t))}_getWindow(){return this._document.defaultView||window}_getFocusOrigin(e){return this._origin?this._originFromTouchInteraction?this._shouldBeAttributedToTouch(e)?"touch":"program":this._origin:this._windowFocused&&this._lastFocusOrigin?this._lastFocusOrigin:e&&this._isLastInteractionFromInputLabel(e)?"mouse":"program"}_shouldBeAttributedToTouch(e){return this._detectionMode===vt.EVENTUAL||!!e?.contains(this._inputModalityDetector._mostRecentTarget)}_setClasses(e,t){e.classList.toggle("cdk-focused",!!t),e.classList.toggle("cdk-touch-focused",t==="touch"),e.classList.toggle("cdk-keyboard-focused",t==="keyboard"),e.classList.toggle("cdk-mouse-focused",t==="mouse"),e.classList.toggle("cdk-program-focused",t==="program")}_setOrigin(e,t=!1){this._ngZone.runOutsideAngular(()=>{if(this._origin=e,this._originFromTouchInteraction=e==="touch"&&t,this._detectionMode===vt.IMMEDIATE){clearTimeout(this._originTimeoutId);let o=this._originFromTouchInteraction?Go:1;this._originTimeoutId=setTimeout(()=>this._origin=null,o)}})}_onFocus(e,t){let o=this._elementInfo.get(t),r=ee(e);!o||!o.checkChildren&&t!==r||this._originChanged(t,this._getFocusOrigin(r),o)}_onBlur(e,t){let o=this._elementInfo.get(t);!o||o.checkChildren&&e.relatedTarget instanceof Node&&t.contains(e.relatedTarget)||(this._setClasses(t),this._emitOrigin(o,null))}_emitOrigin(e,t){e.subject.observers.length&&this._ngZone.run(()=>e.subject.next(t))}_registerGlobalListeners(e){if(!this._platform.isBrowser)return;let t=e.rootNode,o=this._rootNodeFocusListenerCount.get(t)||0;o||this._ngZone.runOutsideAngular(()=>{t.addEventListener("focus",this._rootNodeFocusAndBlurListener,ci),t.addEventListener("blur",this._rootNodeFocusAndBlurListener,ci)}),this._rootNodeFocusListenerCount.set(t,o+1),++this._monitoredElementCount===1&&(this._ngZone.runOutsideAngular(()=>{this._getWindow().addEventListener("focus",this._windowFocusListener)}),this._inputModalityDetector.modalityDetected.pipe(de(this._stopInputModalityDetector)).subscribe(r=>{this._setOrigin(r,!0)}))}_removeGlobalListeners(e){let t=e.rootNode;if(this._rootNodeFocusListenerCount.has(t)){let o=this._rootNodeFocusListenerCount.get(t);o>1?this._rootNodeFocusListenerCount.set(t,o-1):(t.removeEventListener("focus",this._rootNodeFocusAndBlurListener,ci),t.removeEventListener("blur",this._rootNodeFocusAndBlurListener,ci),this._rootNodeFocusListenerCount.delete(t))}--this._monitoredElementCount||(this._getWindow().removeEventListener("focus",this._windowFocusListener),this._stopInputModalityDetector.next(),clearTimeout(this._windowFocusTimeoutId),clearTimeout(this._originTimeoutId))}_originChanged(e,t,o){this._setClasses(e,t),this._emitOrigin(o,t),this._lastFocusOrigin=t}_getClosestElementsInfo(e){let t=[];return this._elementInfo.forEach((o,r)=>{(r===e||o.checkChildren&&r.contains(e))&&t.push([r,o])}),t}_isLastInteractionFromInputLabel(e){let{_mostRecentTarget:t,mostRecentModality:o}=this._inputModalityDetector;if(o!=="mouse"||!t||t===e||e.nodeName!=="INPUT"&&e.nodeName!=="TEXTAREA"||e.disabled)return!1;let r=e.labels;if(r){for(let s=0;s<r.length;s++)if(r[s].contains(t))return!0}return!1}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();var Ko=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275cmp=G({type:n,selectors:[["ng-component"]],exportAs:["cdkVisuallyHidden"],decls:0,vars:0,template:function(t,o){},styles:[`.cdk-visually-hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap;outline:0;-webkit-appearance:none;-moz-appearance:none;left:0}[dir=rtl] .cdk-visually-hidden{left:auto;right:0}
4
4
  `],encapsulation:2,changeDetection:0})}return n})();var as=(()=>{class n{create(e){return typeof MutationObserver>"u"?null:new MutationObserver(e)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();var Xo=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=N({type:n});static \u0275inj=F({providers:[as]})}return n})();var Qi=(()=>{class n{_platform=h(H);constructor(){}isDisabled(e){return e.hasAttribute("disabled")}isVisible(e){return ls(e)&&getComputedStyle(e).visibility==="visible"}isTabbable(e){if(!this._platform.isBrowser)return!1;let t=cs(_s(e));if(t&&(Zo(t)===-1||!this.isVisible(t)))return!1;let o=e.nodeName.toLowerCase(),r=Zo(e);return e.hasAttribute("contenteditable")?r!==-1:o==="iframe"||o==="object"||this._platform.WEBKIT&&this._platform.IOS&&!gs(e)?!1:o==="audio"?e.hasAttribute("controls")?r!==-1:!1:o==="video"?r===-1?!1:r!==null?!0:this._platform.FIREFOX||e.hasAttribute("controls"):e.tabIndex>=0}isFocusable(e,t){return ms(e)&&!this.isDisabled(e)&&(t?.ignoreVisibility||this.isVisible(e))}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function cs(n){try{return n.frameElement}catch{return null}}function ls(n){return!!(n.offsetWidth||n.offsetHeight||typeof n.getClientRects=="function"&&n.getClientRects().length)}function ds(n){let i=n.nodeName.toLowerCase();return i==="input"||i==="select"||i==="button"||i==="textarea"}function hs(n){return fs(n)&&n.type=="hidden"}function us(n){return ps(n)&&n.hasAttribute("href")}function fs(n){return n.nodeName.toLowerCase()=="input"}function ps(n){return n.nodeName.toLowerCase()=="a"}function Jo(n){if(!n.hasAttribute("tabindex")||n.tabIndex===void 0)return!1;let i=n.getAttribute("tabindex");return!!(i&&!isNaN(parseInt(i,10)))}function Zo(n){if(!Jo(n))return null;let i=parseInt(n.getAttribute("tabindex")||"",10);return isNaN(i)?-1:i}function gs(n){let i=n.nodeName.toLowerCase(),e=i==="input"&&n.type;return e==="text"||e==="password"||i==="select"||i==="textarea"}function ms(n){return hs(n)?!1:ds(n)||us(n)||n.hasAttribute("contenteditable")||Jo(n)}function _s(n){return n.ownerDocument&&n.ownerDocument.defaultView||window}var Zi=class{_element;_checker;_ngZone;_document;_injector;_startAnchor;_endAnchor;_hasAttached=!1;startAnchorListener=()=>this.focusLastTabbableElement();endAnchorListener=()=>this.focusFirstTabbableElement();get enabled(){return this._enabled}set enabled(i){this._enabled=i,this._startAnchor&&this._endAnchor&&(this._toggleAnchorTabIndex(i,this._startAnchor),this._toggleAnchorTabIndex(i,this._endAnchor))}_enabled=!0;constructor(i,e,t,o,r=!1,s){this._element=i,this._checker=e,this._ngZone=t,this._document=o,this._injector=s,r||this.attachAnchors()}destroy(){let i=this._startAnchor,e=this._endAnchor;i&&(i.removeEventListener("focus",this.startAnchorListener),i.remove()),e&&(e.removeEventListener("focus",this.endAnchorListener),e.remove()),this._startAnchor=this._endAnchor=null,this._hasAttached=!1}attachAnchors(){return this._hasAttached?!0:(this._ngZone.runOutsideAngular(()=>{this._startAnchor||(this._startAnchor=this._createAnchor(),this._startAnchor.addEventListener("focus",this.startAnchorListener)),this._endAnchor||(this._endAnchor=this._createAnchor(),this._endAnchor.addEventListener("focus",this.endAnchorListener))}),this._element.parentNode&&(this._element.parentNode.insertBefore(this._startAnchor,this._element),this._element.parentNode.insertBefore(this._endAnchor,this._element.nextSibling),this._hasAttached=!0),this._hasAttached)}focusInitialElementWhenReady(i){return new Promise(e=>{this._executeOnStable(()=>e(this.focusInitialElement(i)))})}focusFirstTabbableElementWhenReady(i){return new Promise(e=>{this._executeOnStable(()=>e(this.focusFirstTabbableElement(i)))})}focusLastTabbableElementWhenReady(i){return new Promise(e=>{this._executeOnStable(()=>e(this.focusLastTabbableElement(i)))})}_getRegionBoundary(i){let e=this._element.querySelectorAll(`[cdk-focus-region-${i}], [cdkFocusRegion${i}], [cdk-focus-${i}]`);return i=="start"?e.length?e[0]:this._getFirstTabbableElement(this._element):e.length?e[e.length-1]:this._getLastTabbableElement(this._element)}focusInitialElement(i){let e=this._element.querySelector("[cdk-focus-initial], [cdkFocusInitial]");if(e){if(!this._checker.isFocusable(e)){let t=this._getFirstTabbableElement(e);return t?.focus(i),!!t}return e.focus(i),!0}return this.focusFirstTabbableElement(i)}focusFirstTabbableElement(i){let e=this._getRegionBoundary("start");return e&&e.focus(i),!!e}focusLastTabbableElement(i){let e=this._getRegionBoundary("end");return e&&e.focus(i),!!e}hasAttached(){return this._hasAttached}_getFirstTabbableElement(i){if(this._checker.isFocusable(i)&&this._checker.isTabbable(i))return i;let e=i.children;for(let t=0;t<e.length;t++){let o=e[t].nodeType===this._document.ELEMENT_NODE?this._getFirstTabbableElement(e[t]):null;if(o)return o}return null}_getLastTabbableElement(i){if(this._checker.isFocusable(i)&&this._checker.isTabbable(i))return i;let e=i.children;for(let t=e.length-1;t>=0;t--){let o=e[t].nodeType===this._document.ELEMENT_NODE?this._getLastTabbableElement(e[t]):null;if(o)return o}return null}_createAnchor(){let i=this._document.createElement("div");return this._toggleAnchorTabIndex(this._enabled,i),i.classList.add("cdk-visually-hidden"),i.classList.add("cdk-focus-trap-anchor"),i.setAttribute("aria-hidden","true"),i}_toggleAnchorTabIndex(i,e){i?e.setAttribute("tabindex","0"):e.removeAttribute("tabindex")}toggleAnchors(i){this._startAnchor&&this._endAnchor&&(this._toggleAnchorTabIndex(i,this._startAnchor),this._toggleAnchorTabIndex(i,this._endAnchor))}_executeOnStable(i){this._injector?ne(i,{injector:this._injector}):setTimeout(i)}},qi=(()=>{class n{_checker=h(Qi);_ngZone=h(U);_document=h(M);_injector=h(O);constructor(){h(Ye).load(Ko)}create(e,t=!1){return new Zi(e,this._checker,this._ngZone,this._document,t,this._injector)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();var me=(function(n){return n[n.NONE=0]="NONE",n[n.BLACK_ON_WHITE=1]="BLACK_ON_WHITE",n[n.WHITE_ON_BLACK=2]="WHITE_ON_BLACK",n})(me||{}),Qo="cdk-high-contrast-black-on-white",qo="cdk-high-contrast-white-on-black",Xi="cdk-high-contrast-active",li=(()=>{class n{_platform=h(H);_hasCheckedHighContrastMode;_document=h(M);_breakpointSubscription;constructor(){this._breakpointSubscription=h(Hn).observe("(forced-colors: active)").subscribe(()=>{this._hasCheckedHighContrastMode&&(this._hasCheckedHighContrastMode=!1,this._applyBodyHighContrastModeCssClasses())})}getHighContrastMode(){if(!this._platform.isBrowser)return me.NONE;let e=this._document.createElement("div");e.style.backgroundColor="rgb(1,2,3)",e.style.position="absolute",this._document.body.appendChild(e);let t=this._document.defaultView||window,o=t&&t.getComputedStyle?t.getComputedStyle(e):null,r=(o&&o.backgroundColor||"").replace(/ /g,"");switch(e.remove(),r){case"rgb(0,0,0)":case"rgb(45,50,54)":case"rgb(32,32,32)":return me.WHITE_ON_BLACK;case"rgb(255,255,255)":case"rgb(255,250,239)":return me.BLACK_ON_WHITE}return me.NONE}ngOnDestroy(){this._breakpointSubscription.unsubscribe()}_applyBodyHighContrastModeCssClasses(){if(!this._hasCheckedHighContrastMode&&this._platform.isBrowser&&this._document.body){let e=this._document.body.classList;e.remove(Xi,Qo,qo),this._hasCheckedHighContrastMode=!0;let t=this.getHighContrastMode();t===me.BLACK_ON_WHITE?e.add(Xi,Qo):t===me.WHITE_ON_BLACK&&e.add(Xi,qo)}}static \u0275fac=function(t){return new(t||n)};static \u0275prov=b({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),Ji=(()=>{class n{constructor(){h(li)._applyBodyHighContrastModeCssClasses()}static \u0275fac=function(t){return new(t||n)};static \u0275mod=N({type:n});static \u0275inj=F({imports:[Xo]})}return n})();function vs(n,i){}var _e=class{viewContainerRef;injector;id;role="dialog";panelClass="";hasBackdrop=!0;backdropClass="";disableClose=!1;closePredicate;width="";height="";minWidth;minHeight;maxWidth;maxHeight;positionStrategy;data=null;direction;ariaDescribedBy=null;ariaLabelledBy=null;ariaLabel=null;ariaModal=!1;autoFocus="first-tabbable";restoreFocus=!0;scrollStrategy;closeOnNavigation=!0;closeOnDestroy=!0;closeOnOverlayDetachments=!0;disableAnimations=!1;providers;container;templateContext};var tn=(()=>{class n extends We{_elementRef=h(R);_focusTrapFactory=h(qi);_config;_interactivityChecker=h(Qi);_ngZone=h(U);_focusMonitor=h(Ki);_renderer=h(Fe);_changeDetectorRef=h($e);_injector=h(O);_platform=h(H);_document=h(M);_portalOutlet;_focusTrapped=new y;_focusTrap=null;_elementFocusedBeforeDialogWasOpened=null;_closeInteractionType=null;_ariaLabelledByQueue=[];_isDestroyed=!1;constructor(){super(),this._config=h(_e,{optional:!0})||new _e,this._config.ariaLabelledBy&&this._ariaLabelledByQueue.push(this._config.ariaLabelledBy)}_addAriaLabelledBy(e){this._ariaLabelledByQueue.push(e),this._changeDetectorRef.markForCheck()}_removeAriaLabelledBy(e){let t=this._ariaLabelledByQueue.indexOf(e);t>-1&&(this._ariaLabelledByQueue.splice(t,1),this._changeDetectorRef.markForCheck())}_contentAttached(){this._initializeFocusTrap(),this._captureInitialFocus()}_captureInitialFocus(){this._trapFocus()}ngOnDestroy(){this._focusTrapped.complete(),this._isDestroyed=!0,this._restoreFocus()}attachComponentPortal(e){this._portalOutlet.hasAttached();let t=this._portalOutlet.attachComponentPortal(e);return this._contentAttached(),t}attachTemplatePortal(e){this._portalOutlet.hasAttached();let t=this._portalOutlet.attachTemplatePortal(e);return this._contentAttached(),t}attachDomPortal=e=>{this._portalOutlet.hasAttached();let t=this._portalOutlet.attachDomPortal(e);return this._contentAttached(),t};_recaptureFocus(){this._containsFocus()||this._trapFocus()}_forceFocus(e,t){this._interactivityChecker.isFocusable(e)||(e.tabIndex=-1,this._ngZone.runOutsideAngular(()=>{let o=()=>{r(),s(),e.removeAttribute("tabindex")},r=this._renderer.listen(e,"blur",o),s=this._renderer.listen(e,"mousedown",o)})),e.focus(t)}_focusByCssSelector(e,t){let o=this._elementRef.nativeElement.querySelector(e);o&&this._forceFocus(o,t)}_trapFocus(e){this._isDestroyed||ne(()=>{let t=this._elementRef.nativeElement;switch(this._config.autoFocus){case!1:case"dialog":this._containsFocus()||t.focus(e);break;case!0:case"first-tabbable":this._focusTrap?.focusInitialElement(e)||this._focusDialogContainer(e);break;case"first-heading":this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]',e);break;default:this._focusByCssSelector(this._config.autoFocus,e);break}this._focusTrapped.next()},{injector:this._injector})}_restoreFocus(){let e=this._config.restoreFocus,t=null;if(typeof e=="string"?t=this._document.querySelector(e):typeof e=="boolean"?t=e?this._elementFocusedBeforeDialogWasOpened:null:e&&(t=e),this._config.restoreFocus&&t&&typeof t.focus=="function"){let o=Yt(),r=this._elementRef.nativeElement;(!o||o===this._document.body||o===r||r.contains(o))&&(this._focusMonitor?(this._focusMonitor.focusVia(t,this._closeInteractionType),this._closeInteractionType=null):t.focus())}this._focusTrap&&this._focusTrap.destroy()}_focusDialogContainer(e){this._elementRef.nativeElement.focus?.(e)}_containsFocus(){let e=this._elementRef.nativeElement,t=Yt();return e===t||e.contains(t)}_initializeFocusTrap(){this._platform.isBrowser&&(this._focusTrap=this._focusTrapFactory.create(this._elementRef.nativeElement),this._document&&(this._elementFocusedBeforeDialogWasOpened=Yt()))}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=G({type:n,selectors:[["cdk-dialog-container"]],viewQuery:function(t,o){if(t&1&&Tt(ut,7),t&2){let r;xt(r=Pt())&&(o._portalOutlet=r.first)}},hostAttrs:["tabindex","-1",1,"cdk-dialog-container"],hostVars:6,hostBindings:function(t,o){t&2&&ue("id",o._config.id||null)("role",o._config.role)("aria-modal",o._config.ariaModal)("aria-labelledby",o._config.ariaLabel?null:o._ariaLabelledByQueue[0])("aria-label",o._config.ariaLabel)("aria-describedby",o._config.ariaDescribedBy||null)},features:[W],decls:1,vars:0,consts:[["cdkPortalOutlet",""]],template:function(t,o){t&1&&kt(0,vs,0,0,"ng-template",0)},dependencies:[ut],styles:[`.cdk-dialog-container{display:block;width:100%;height:100%;min-height:inherit;max-height:inherit}
@@ -1 +1 @@
1
- import{i as V}from"./chunk-RNFB3ETM.js";import{Ga as x,Ha as L,Ja as D,M as C,R as v,S as I}from"./chunk-3WXPNBX5.js";import{Wa as m,_a as d,_i as y,a as s,b as h,fa as o,oj as E,qj as U,sa as f,xc as u,ya as S,zc as p}from"./chunk-XUBWZTRK.js";var A=(()=>{let r=class r extends D{set parentLocalUIState(t){try{t&&(this.localUIStateSignal=t,this.isLocalUIStateOwner=!1,this._localUIStateFromExplicitInput=!0)}catch{}}get elementRef(){try{return this.hostElementRef}catch{return null}}getServiceComponentConfigSignal(){}constructor(){let t=o(S),e=o(L),i=o(p),a=o(E).get(y),g=o(x),l=o(U);super(t,e,i,a??void 0,void 0,g,l),this.defaultCondition=u(!0,{transform:n=>{try{return typeof n=="string"?n==="true"||n==="":n}catch{return!0}}}),this.isLocalUIStateOwner=!1,this._localUIStateFromExplicitInput=!1,this.veltContextHost=new V({getHost:()=>this.hostElementRef?.nativeElement,ownerRef:this,getEntity:()=>this.getPublishedVeltEntity(),getLocalUIState:()=>this.isLocalUIStateOwner?this.localUIStateSignal:void 0,onContextChanged:()=>{this.adoptInheritedLocalUIState(),this.rebindServiceConfigFromPlacement(),this.onVeltContextChanged()},markForCheck:()=>this.cd?.markForCheck()}),this.isLocalUIStateRoot=!1,this.selfConnectedConfig=!1,this.ownsConfigSignal=!0;try{this.hostElementRef=t,this.themeService=e,this.dynamicDataService=g,this.loggingService=l,this.cd=i,this.commentService=a??void 0,this.initializeLocalUIState()}catch(n){this.loggingService=this.loggingService||l,this.loggingService?.catch?.("Error in V2PrimitiveThemedBase constructor:",n)}}initializeLocalUIState(){this.localUIStateSignal=f(this.getDefaultLocalUIState()),this.isLocalUIStateOwner=!0}getConditionalClassesContext(){return{componentConfigSignal:this.componentConfigSignal}}ngOnInit(){try{this.adoptInheritedLocalUIState(),this.connectToServiceSignalIfStandalone(),this.dynamicDataService.applyConditionalClasses(this.hostElementRef?.nativeElement,this.getConditionalClassesContext()),this.setupA11yAttributes(),this.isLocalUIStateOwner&&this.setupDarkModeSync(),this.finalizeVeltContext()}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase ngOnInit:",t)}}adoptInheritedLocalUIState(){try{v({host:this.hostElementRef?.nativeElement,current:this.localUIStateSignal,isOwner:this.isLocalUIStateOwner,fromExplicitInput:this._localUIStateFromExplicitInput,isRoot:this.isLocalUIStateRoot,adopt:t=>{this.localUIStateSignal=t,this.isLocalUIStateOwner=!1}})}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase adoptInheritedLocalUIState:",t)}}rebindServiceConfigFromPlacement(){try{if(!this.selfConnectedConfig)return;let t=this.getServiceComponentConfigSignal();if(!t||t===this.componentConfigSignal)return;let e=this.componentConfigSignal,i=this.ownsConfigSignal;if(this.componentConfigSignal=t,this.ownsConfigSignal=!1,i)try{e?.update(a=>s({},a))}catch{}this.cd?.markForCheck()}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase rebindServiceConfigFromPlacement:",t)}}finalizeVeltContext(){this.veltContextHost.finalize()}getPublishedVeltEntity(){}getInheritedVeltEntity(){try{return I(this.hostElementRef?.nativeElement)}catch{return}}refreshVeltContextFromPlacement(){this.veltContextHost.refreshFromPlacement()}onVeltContextChanged(){}getInheritedVeltContextData(){try{return C(this.hostElementRef?.nativeElement)?.payload?.contextData||{}}catch{return{}}}connectToServiceSignalIfStandalone(){try{let t=this.componentConfigSignal();if(!t||!t?.uiState){this.selfConnectedConfig=!0;let e=this.getServiceComponentConfigSignal();e&&(this.componentConfigSignal=e,this.ownsConfigSignal=!1)}}catch(t){this.loggingService.catch("Error connecting to service signal:",t)}}ngOnDestroy(){try{this.darkModeConfigSyncSubscription&&this.darkModeConfigSyncSubscription.unsubscribe(),this.veltContextHost.destroy(),super.ngOnDestroy()}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase ngOnDestroy:",t)}}setupA11yAttributes(){}setupDarkModeSync(){try{this.darkModeConfigSyncSubscription=this.onDarkModeChange().subscribe(t=>{try{if(this.componentConfigSignal&&typeof this.componentConfigSignal=="function"){let e=this.componentConfigSignal();e&&e.uiState&&e.uiState.darkMode!==t&&this.componentConfigSignal.update(i=>h(s({},i),{uiState:h(s({},i.uiState),{darkMode:t})}))}}catch(e){this.loggingService.catch("Error in darkMode sync subscription:",e)}})}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase setupDarkModeSync:",t)}}};r.\u0275fac=function(e){return new(e||r)},r.\u0275cmp=m({type:r,selectors:[["app-v2-primitive-themed-base"]],inputs:{defaultCondition:[1,"defaultCondition"],parentLocalUIState:"parentLocalUIState"},standalone:!1,features:[d],decls:0,vars:0,template:function(e,i){},encapsulation:2});let c=r;return c})();export{A as a};
1
+ import{i as V}from"./chunk-4Z5OANZ2.js";import{Ga as x,Ha as L,Ja as D,M as C,R as v,S as I}from"./chunk-3COV4GP2.js";import{Wa as m,_a as d,_i as y,a as s,b as h,fa as o,oj as E,qj as U,sa as f,xc as u,ya as S,zc as p}from"./chunk-UQB52CCU.js";var A=(()=>{let r=class r extends D{set parentLocalUIState(t){try{t&&(this.localUIStateSignal=t,this.isLocalUIStateOwner=!1,this._localUIStateFromExplicitInput=!0)}catch{}}get elementRef(){try{return this.hostElementRef}catch{return null}}getServiceComponentConfigSignal(){}constructor(){let t=o(S),e=o(L),i=o(p),a=o(E).get(y),g=o(x),l=o(U);super(t,e,i,a??void 0,void 0,g,l),this.defaultCondition=u(!0,{transform:n=>{try{return typeof n=="string"?n==="true"||n==="":n}catch{return!0}}}),this.isLocalUIStateOwner=!1,this._localUIStateFromExplicitInput=!1,this.veltContextHost=new V({getHost:()=>this.hostElementRef?.nativeElement,ownerRef:this,getEntity:()=>this.getPublishedVeltEntity(),getLocalUIState:()=>this.isLocalUIStateOwner?this.localUIStateSignal:void 0,onContextChanged:()=>{this.adoptInheritedLocalUIState(),this.rebindServiceConfigFromPlacement(),this.onVeltContextChanged()},markForCheck:()=>this.cd?.markForCheck()}),this.isLocalUIStateRoot=!1,this.selfConnectedConfig=!1,this.ownsConfigSignal=!0;try{this.hostElementRef=t,this.themeService=e,this.dynamicDataService=g,this.loggingService=l,this.cd=i,this.commentService=a??void 0,this.initializeLocalUIState()}catch(n){this.loggingService=this.loggingService||l,this.loggingService?.catch?.("Error in V2PrimitiveThemedBase constructor:",n)}}initializeLocalUIState(){this.localUIStateSignal=f(this.getDefaultLocalUIState()),this.isLocalUIStateOwner=!0}getConditionalClassesContext(){return{componentConfigSignal:this.componentConfigSignal}}ngOnInit(){try{this.adoptInheritedLocalUIState(),this.connectToServiceSignalIfStandalone(),this.dynamicDataService.applyConditionalClasses(this.hostElementRef?.nativeElement,this.getConditionalClassesContext()),this.setupA11yAttributes(),this.isLocalUIStateOwner&&this.setupDarkModeSync(),this.finalizeVeltContext()}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase ngOnInit:",t)}}adoptInheritedLocalUIState(){try{v({host:this.hostElementRef?.nativeElement,current:this.localUIStateSignal,isOwner:this.isLocalUIStateOwner,fromExplicitInput:this._localUIStateFromExplicitInput,isRoot:this.isLocalUIStateRoot,adopt:t=>{this.localUIStateSignal=t,this.isLocalUIStateOwner=!1}})}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase adoptInheritedLocalUIState:",t)}}rebindServiceConfigFromPlacement(){try{if(!this.selfConnectedConfig)return;let t=this.getServiceComponentConfigSignal();if(!t||t===this.componentConfigSignal)return;let e=this.componentConfigSignal,i=this.ownsConfigSignal;if(this.componentConfigSignal=t,this.ownsConfigSignal=!1,i)try{e?.update(a=>s({},a))}catch{}this.cd?.markForCheck()}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase rebindServiceConfigFromPlacement:",t)}}finalizeVeltContext(){this.veltContextHost.finalize()}getPublishedVeltEntity(){}getInheritedVeltEntity(){try{return I(this.hostElementRef?.nativeElement)}catch{return}}refreshVeltContextFromPlacement(){this.veltContextHost.refreshFromPlacement()}onVeltContextChanged(){}getInheritedVeltContextData(){try{return C(this.hostElementRef?.nativeElement)?.payload?.contextData||{}}catch{return{}}}connectToServiceSignalIfStandalone(){try{let t=this.componentConfigSignal();if(!t||!t?.uiState){this.selfConnectedConfig=!0;let e=this.getServiceComponentConfigSignal();e&&(this.componentConfigSignal=e,this.ownsConfigSignal=!1)}}catch(t){this.loggingService.catch("Error connecting to service signal:",t)}}ngOnDestroy(){try{this.darkModeConfigSyncSubscription&&this.darkModeConfigSyncSubscription.unsubscribe(),this.veltContextHost.destroy(),super.ngOnDestroy()}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase ngOnDestroy:",t)}}setupA11yAttributes(){}setupDarkModeSync(){try{this.darkModeConfigSyncSubscription=this.onDarkModeChange().subscribe(t=>{try{if(this.componentConfigSignal&&typeof this.componentConfigSignal=="function"){let e=this.componentConfigSignal();e&&e.uiState&&e.uiState.darkMode!==t&&this.componentConfigSignal.update(i=>h(s({},i),{uiState:h(s({},i.uiState),{darkMode:t})}))}}catch(e){this.loggingService.catch("Error in darkMode sync subscription:",e)}})}catch(t){this.loggingService.catch("Error in V2PrimitiveThemedBase setupDarkModeSync:",t)}}};r.\u0275fac=function(e){return new(e||r)},r.\u0275cmp=m({type:r,selectors:[["app-v2-primitive-themed-base"]],inputs:{defaultCondition:[1,"defaultCondition"],parentLocalUIState:"parentLocalUIState"},standalone:!1,features:[d],decls:0,vars:0,template:function(e,i){},encapsulation:2});let c=r;return c})();export{A as a};
@@ -1 +1 @@
1
- import{Fa as ge}from"./chunk-3WXPNBX5.js";import{B as le,D as ue,E as he,b as oe,m as ne,n as ce,p as ae,s as de}from"./chunk-UM4DCTY2.js";import{$f as T,Bk as ie,He as b,Ii as E,Ji as $,M as F,Nj as ee,Pf as p,Qd as B,Qf as g,Qj as re,Uj as se,_f as j,a as v,ag as _,b as O,ba as L,cg as k,dg as D,di as V,ea as R,ee as S,fa as z,g as m,gi as q,hi as X,kg as J,ki as H,l as N,mi as K,oi as x,qj as Y,rj as Q,sf as U,tf as P,uf as I,v as W,vg as G,wj as Z,wk as te}from"./chunk-XUBWZTRK.js";var A="public",w=100,fe=50,$e=(()=>{let C=class C{constructor(e,r,s,t,i,o,c,a,n,d){this.authService=e,this.docService=r,this.loggingService=s,this.commonDbService=t,this.usersService=i,this.commentUtilsService=o,this.coreActionsService=c,this.functions=a,this.configService=n,this.contactService=d,this.endpointsService=z(Z),this.adapterSelectorService=z(se),this.currentUserPermissions$=new N(null),this.permissionsCache$=new N(null),this.permissionProvider$=new N(null),this.clientResolverProdWarned=!1,this.clientResolverNoResolverWarned=!1,this.requestKeyedPermissionsCache=new Map,this.inFlightPermissionsRequests=new Map,this.permissionsCacheGeneration=0,this.REVOKE_DELAY_MS=3e3,this.pendingRevokeRequests=new Map,this.pendingRevokeTimeoutId=null,this.pendingRevokeUniqueId="",this.pendingRevokeUserId="",this.reportedPortablePermissionFailures=new Set,this.clientResolverContradictionWarned=!1,this.reportedUnknownFolderErrorCodes=new Set;try{this.docService.setUserPermissionService(this),this.authService.setUserPermissionService(this),this.commentUtilsService.setUserPermissionService(this),this.contactService.setUserPermissionService(this)}catch(l){this.loggingService.catch("Error in UserPermissionService constructor:",l)}}ngOnDestroy(){try{this.pendingRevokeTimeoutId&&(clearTimeout(this.pendingRevokeTimeoutId),this.pendingRevokeTimeoutId=null)}catch(e){this.loggingService.catch("Error in UserPermissionService ngOnDestroy:",e)}}collectRevokeRequest(e,r,s,t,i,o){try{return e.find(a=>a.resourceId===s&&a.type===t&&a.organizationId===i&&a.userId===o)?(r.push({userId:o,resourceId:s,organizationId:i,type:t,hasAccess:!1}),e.filter(a=>!(a.resourceId===s&&a.type===t&&a.organizationId===i&&a.userId===o))):e}catch(c){return this.loggingService.catch("Error in UsersPermissionService collectRevokeRequest:",c),e}}hasUserContextAccess({userId:e,accessFields:r}){try{if(!this.getIsContextEnabled()||r.includes(b.DEFAULT_VELT_CONTEXT))return!0;let s=r.filter(i=>!J(i));if(!s.length){if(r.some(c=>c.startsWith(b.VISIBILITY_ORG_PREFIX)))return!0;let o=`${b.VISIBILITY_SELF_PREFIX}${j(e).toString()}`;return r.includes(o)}let t=this.contactService.getUserAccessFieldsByUserId(e);return t?.length?s.every(i=>t.includes(i)):!0}catch(s){return this.loggingService.catch("Error in UserPermissionService hasUserContextAccess:",s),!1}}isMetadataProbeUnanswerable(e){try{return this.adapterSelectorService?.isPortableBackendActive()?!ne(e)&&!ce(e):!1}catch(r){return this.loggingService.catch("Error in UserPermissionService isMetadataProbeUnanswerable: ",r),!1}}organizationDetails(e){return m(this,null,function*(){try{if(this.isMetadataProbeUnanswerable("organizationMetadata"))return{error:!1};let r=yield this.commonDbService?.getData({feature:"organizationMetadata",properties:{organizationId:e,suppressError:!0}});return r&&r?.errorCode?{errorCode:g.PERMISSION_DENIED,error:!0}:r&&!r?.metadata?{errorCode:g.DOES_NOT_EXIST,error:!0}:{error:!1}}catch(r){return this.loggingService.catch("Error in UserPermissionService organizationDetails:",r),{errorCode:g.SOMETHING_WENT_WRONG,error:!0}}})}documentDetails(i){return m(this,arguments,function*({documentId:e,organizationId:r,clientDocumentId:s,clientOrganizationId:t}){try{if(this.isMetadataProbeUnanswerable("documentMetadata")){let d=yield this.docService.readPortableDocumentForProbe?.(e,s,t);return d?.missing?{errorCode:g.DOES_NOT_EXIST,error:!0}:d?.accessType?{error:!1,accessType:d.accessType}:{error:!1}}let o=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:e,organizationId:r,suppressError:!0}});if(o&&o?.errorCode)return{errorCode:g.PERMISSION_DENIED,error:!0};if(o&&!o?.metadata)return{errorCode:g.DOES_NOT_EXIST,error:!0};let c=this.docService.getDocumentMetadata(e)??{};this.docService.setDocumentMetadata(e,v(v({},c),o?.metadata??{}));let a,n=o?.metadata?.veltFolderId;if(n)try{a=(yield this.commonDbService?.getData({feature:"folderMetadata",properties:{folderId:n,organizationId:r}}))?.folderIamConfig?.accessType}catch(d){this.loggingService.catch("Error fetching folder accessType for document:",d)}return a||(a=o?.docIamConfig?.accessType),{error:!1,accessType:a}}catch(o){return this.loggingService.catch("Error in UserPermissionService documentDetails:",o),{errorCode:g.SOMETHING_WENT_WRONG,error:!0}}})}folderDetails(s){return m(this,arguments,function*({folderId:e,organizationId:r}){try{if(this.isMetadataProbeUnanswerable("folderMetadata"))return{error:!1};let t=yield this.commonDbService?.getData({feature:"folderMetadata",properties:{folderId:e,organizationId:r,suppressError:!0}});return t&&t?.errorCode?{errorCode:g.PERMISSION_DENIED,error:!0}:t&&!t?.metadata?{errorCode:g.DOES_NOT_EXIST,error:!0}:{error:!1,accessType:t?.folderIamConfig?.accessType}}catch(t){return this.loggingService.catch("Error in UserPermissionService folderDetails:",t),{errorCode:g.SOMETHING_WENT_WRONG,error:!0}}})}getUserPermissions(e){return m(this,null,function*(){let r=this.permissionsCacheGeneration;try{if(!this.authService.getUser())return this.loggingService.catch("User not set. [source: getUserPermissions]",void 0,void 0,!0),{};let s=this.authService.getUser()?.userId,t=this.extractResourceIds(e);if(!t.clientOrganizationId||!t.organizationId)return this.loggingService.catch("Client organization id or organization id not set during getUserPermissions",void 0,void 0,!0),{};let i=this.adapterSelectorService?.isPortableSession?.()===!0;if(i&&this.adapterSelectorService?.isPortableBackendActive?.()!==!0&&(yield re(C.PORTABLE_ACTIVATION_WAIT_MS),s!==this.authService.getUser()?.userId))return{};let o=yield this.validateResources(t),c;if(i&&this.adapterSelectorService?.isPortableBackendActive?.()===!0){if(c=yield this.fetchPortableUserPermissions(t,o,s??""),s!==this.authService.getUser()?.userId)return{}}else{let[a,n]=yield this.fetchUserPermissionsFromDB(t),d=this.authService.getUser()?.userId;if(s!==d)return{};c=this.buildPermissionsResponse(t,o,a,n)}if(Object.keys(c).length>0){if(!e)this.setCurrentUserPermissions(c);else if(this.permissionsCacheGeneration===r){let a=this.buildPermissionsCacheKey(e);a!==null&&this.requestKeyedPermissionsCache.set(a,JSON.parse(JSON.stringify(c)))}}return c}catch(s){return this.loggingService.catch("Error in UserPermissionService getUserPermissions:",s),{}}})}getUserPermissionsFromCacheOrFetch(e){return m(this,null,function*(){try{if(!e)return yield this.getUserPermissions(e);let r=this.buildPermissionsCacheKey(e);if(r===null)return yield this.getUserPermissions(e);let s=this.permissionsCacheGeneration,t=this.requestKeyedPermissionsCache.get(r);if(t)return JSON.parse(JSON.stringify(t));let i=this.inFlightPermissionsRequests.get(r);if(i){let a=yield i;return this.permissionsCacheGeneration!==s?yield this.getUserPermissions(e):JSON.parse(JSON.stringify(a))}let o=this.getUserPermissions(e);this.inFlightPermissionsRequests.set(r,o),o.finally(()=>{this.inFlightPermissionsRequests.get(r)===o&&this.inFlightPermissionsRequests.delete(r)}).catch(()=>{});let c=yield o;return this.permissionsCacheGeneration!==s?yield this.getUserPermissions(e):JSON.parse(JSON.stringify(c))}catch(r){return this.loggingService.catch("Error in UserPermissionService getUserPermissionsFromCacheOrFetch:",r),{}}})}clearRequestKeyedPermissionsCache(){try{this.requestKeyedPermissionsCache.clear(),this.inFlightPermissionsRequests.clear(),this.permissionsCacheGeneration++}catch(e){this.loggingService.catch("Error in UserPermissionService clearRequestKeyedPermissionsCache:",e)}}invalidateAllPermissionsState(){try{this.reportedPortablePermissionFailures?.clear(),this.requestKeyedPermissionsCache.clear(),this.inFlightPermissionsRequests.clear(),this.permissionsCacheGeneration++}catch(e){this.loggingService.catch("Error in UserPermissionService invalidateAllPermissionsState:",e)}}buildPermissionsCacheKey(e){try{let r={};return Object.keys(e).sort().forEach(s=>{let t=e[s];t!==void 0&&(r[s]=Array.isArray(t)?[...t].sort():t)}),r.__userId=this.authService.getUser()?.userId??null,JSON.stringify(r)}catch(r){return this.loggingService.catch("Error in UserPermissionService buildPermissionsCacheKey:",r),null}}extractResourceIds(e){let r=this.docService.getDocumentPaths(),s=this.docService.getDocumentIds();if(e){let o=e.organizationId??r?.clientOrganizationId;return{folderIds:e.folderIds??[],documentIds:e.documentIds??[],clientOrganizationId:o,organizationId:o?k(o):void 0}}let t=r?.clientOrganizationId;return{folderIds:r?.folderId?[r.folderId]:[],documentIds:s.map(o=>o.clientDocumentId),clientOrganizationId:t,organizationId:t?k(t):void 0}}validateResources(e){return m(this,null,function*(){let{folderIds:r,documentIds:s,organizationId:t,clientOrganizationId:i}=e,o=[],c=[],a=r.length>0||s.length>0;t&&!a&&(o.push(this.organizationDetails(t)),c.push({id:i??"",type:"organization"})),r.forEach(u=>{o.push(this.folderDetails({folderId:D(u),organizationId:t??""})),c.push({id:u,type:"folder"})}),s.forEach(u=>{o.push(this.documentDetails({documentId:_(u),organizationId:t??"",clientDocumentId:u,clientOrganizationId:i})),c.push({id:u,type:"document"})});let[n,d]=yield Promise.all([Promise.allSettled(o),this.getDefaultDocumentAccessType()]),l=this.processValidationResults(n,c);return O(v({},this.suppressResolverGrantedFailures(l,i)),{defaultDocumentAccessType:d})})}suppressResolverGrantedFailures(e,r){try{let s=this.authService.getUser()?.userId;if(!s)return e;let t=this.getPermissionsCache()??[];if(t.length===0)return e;let i=(n,d,l)=>t.some(u=>u?.userId===s&&u?.resourceId===n&&u?.type===d&&(!l||u?.organizationId===l)&&u?.hasAccess===!0),o=e.failedDocumentIds.filter(n=>!(n.errorCode===g.PERMISSION_DENIED&&i(n.id,I.DOCUMENT,r))),c=e.failedFolderIds.filter(n=>!(n.errorCode===g.PERMISSION_DENIED&&i(n.id,I.FOLDER,r))),a=e.failedOrganizationId;return a&&a.errorCode===g.PERMISSION_DENIED&&r&&i(r,I.ORGANIZATION,r)&&(a=void 0),{failedFolderIds:c,failedDocumentIds:o,failedOrganizationId:a,folderAccessTypes:e.folderAccessTypes,documentAccessTypes:e.documentAccessTypes}}catch(s){return this.loggingService.catch("Error in UserPermissionService suppressResolverGrantedFailures:",s),e}}getDefaultDocumentAccessType(){return m(this,null,function*(){try{return(yield this.commonDbService?.getData({feature:"apiKeyMetadata",properties:{}}))?.defaultDocumentAccessType}catch(e){this.loggingService.catch("Error fetching defaultDocumentAccessType:",e);return}})}processValidationResults(e,r){let s=[],t=[],i,o={},c={};for(let a=0;a<e.length;a++){let n=e[a],d=r[a];if(n.status==="rejected"||n.status==="fulfilled"&&n.value.error){let u=n.status==="fulfilled"?n.value.errorCode??g.SOMETHING_WENT_WRONG:g.SOMETHING_WENT_WRONG,h={id:d.id,errorCode:u};switch(d.type){case"organization":if(i=h,u===g.DOES_NOT_EXIST)throw new Error(`Organization with id '${d.id}' does not exist`);break;case"folder":s.push(h);break;case"document":t.push(h);break}}else if(n.status==="fulfilled")switch(d.type){case"folder":n.value.accessType&&(o[d.id]=n.value.accessType);break;case"document":n.value.accessType&&(c[d.id]=n.value.accessType);break}}return{failedFolderIds:s,failedDocumentIds:t,failedOrganizationId:i,folderAccessTypes:o,documentAccessTypes:c}}fetchPortableUserPermissions(e,r,s){return m(this,null,function*(){try{let t=e.clientOrganizationId??"";if(!s||!t)return{};let i=fe,o=T(e.folderIds??[],i),c=T(e.documentIds??[],i),a=Math.max(o.length,c.length,1),n={},d=this.adapterSelectorService.resolveDbAdapter();for(let h=0;h<a;h++){let f={organizationId:t,userIds:[s]};o[h]?.length&&(f.folderIds=o[h]),c[h]?.length&&(f.documentIds=c[h]);let y=yield ee(d,"getUserPermissions",{scope:"org",data:f});if(!y?.ok)return oe("getUserPermissions",y,{logCatch:(me,ve)=>this.loggingService.catch(me,ve,void 0,!0),reported:this.reportedPortablePermissionFailures,isOutcomeUnknown:le}),{};this.reportedPortablePermissionFailures.clear(),this.mergePortablePermissionsMap(n,this.readPortablePermissionsMap(y.data,s))}let l=n[s],u=l?{[s]:l}:{};return l&&(Object.entries(l.documents??{}).forEach(([h,f])=>{if(f&&!f.accessType){let y=r.documentAccessTypes?.[h]??r.defaultDocumentAccessType;y&&(f.accessType=y)}}),Object.entries(l.folders??{}).forEach(([h,f])=>{if(f&&!f.accessType){let y=r.folderAccessTypes?.[h]??r.defaultDocumentAccessType;y&&(f.accessType=y)}})),this.ensureCurrentUserFailuresRecorded(u,t,r.failedFolderIds,r.failedDocumentIds,r.failedOrganizationId,r.folderAccessTypes,r.documentAccessTypes,r.defaultDocumentAccessType),this.processContextPermissions(u),u}catch(t){return this.loggingService.catch("Error in UserPermissionService fetchPortableUserPermissions: ",t),{}}})}readPortablePermissionsMap(e,r){let s=c=>!!c&&typeof c=="object"&&!Array.isArray(c);if(!s(e))return{};let t=new Set(["data","success","statusCode","message"]),i=Object.keys(e);return r!=="data"&&s(e.data)&&i.every(c=>t.has(c))?e.data:e}mergePortablePermissionsMap(e,r){Object.entries(r??{}).forEach(([s,t])=>{if(!t||typeof t!="object")return;let i=e[s]??(e[s]={});t.folders&&(i.folders=v(v({},i.folders??{}),t.folders)),t.documents&&(i.documents=v(v({},i.documents??{}),t.documents)),t.organization&&(i.organization=v(v({},i.organization??{}),t.organization)),t.context&&(i.context=t.context)})}fetchUserPermissionsFromDB(e){return m(this,null,function*(){let{folderIds:r,documentIds:s,organizationId:t}=e,i=[this.authService.getUser()?.userId??""],o=[...r.map(n=>D(n)),...s.map(n=>_(n)),t??""],[c,a]=yield Promise.allSettled([this.usersService.getUsersFromDBWithBatching({userIds:i,organizationId:t}),this.usersService.getTemporaryUsersFromDBWithBatching({userIds:i,organizationId:t,resourceIds:o})]);return[c.status==="fulfilled"?c.value:[],a.status==="fulfilled"?a.value:[]]})}buildPermissionsResponse(e,r,s,t){let{folderIds:i,documentIds:o,clientOrganizationId:c,organizationId:a}=e,{failedFolderIds:n,failedDocumentIds:d,failedOrganizationId:l}=r,u={};return this.processRegularUserPermissions(u,s,i,o,c??"",a??"",n,d,l,r.folderAccessTypes,r.documentAccessTypes,r.defaultDocumentAccessType),this.ensureCurrentUserFailuresRecorded(u,c??"",n,d,l,r.folderAccessTypes,r.documentAccessTypes,r.defaultDocumentAccessType),this.processTemporaryUserPermissions(u,t),this.processContextPermissions(u),u}processContextPermissions(e){try{let r=this.authService.getUser()?.userId;if(r){let s=this.contactService.getUserAccessFieldsByUserId(r);s?.length&&(e[r]||(e[r]={}),e[r].context={accessFields:s})}}catch(r){this.loggingService.catch("Error in UserPermissionService processContextPermissions:",r);return}}processRegularUserPermissions(e,r,s,t,i,o,c,a,n,d,l,u){for(let h of r)for(let f of h)f?.user?.userId&&(e[f.user.userId]=O(v({},s.length&&{folders:this.buildFolderPermissions(s,f,c,d,u)}),{documents:this.buildDocumentPermissions(t,f,a,l,u),organization:{[i]:this.buildOrganizationPermission(o,f,n)}}))}ensureCurrentUserFailuresRecorded(e,r,s,t,i,o,c,a){try{let n=this.authService.getUser()?.userId;if(!n)return;let d=!!i&&!!r,l=(s?.length??0)>0,u=(t?.length??0)>0;if(!d&&!l&&!u)return;if(e[n]||(e[n]={}),d&&(e[n].organization||(e[n].organization={}),e[n].organization[r]||(e[n].organization[r]={error:this.getErrorMessage(i.errorCode,"organization"),errorCode:i.errorCode})),l){e[n].folders||(e[n].folders={});for(let h of s)e[n].folders[h.id]||(e[n].folders[h.id]=v({error:this.getErrorMessage(h.errorCode,"folder"),errorCode:h.errorCode},h.errorCode===g.PERMISSION_DENIED&&{accessType:o[h.id]??a??A}))}if(u){e[n].documents||(e[n].documents={});for(let h of t)e[n].documents[h.id]||(e[n].documents[h.id]=v({error:this.getErrorMessage(h.errorCode,"document"),errorCode:h.errorCode},h.errorCode===g.PERMISSION_DENIED&&{accessType:c[h.id]??a??A}))}}catch(n){this.loggingService.catch("Error in UserPermissionService ensureCurrentUserFailuresRecorded:",n)}}getErrorMessage(e,r){try{switch(this.loggingService.log(`Error in UserPermissionService getErrorMessage: ${e} ${r}`),e){case g.DOES_NOT_EXIST:return`${r} does not exist`;case g.PERMISSION_DENIED:return`User does not have access to ${r}`;case g.SOMETHING_WENT_WRONG:return"Something went wrong";default:return"Something went wrong"}}catch(s){return this.loggingService.catch("Error in UserPermissionService getErrorMessage:",s),"Something went wrong"}}buildFolderPermissions(e,r,s,t,i){return e.reduce((o,c)=>{let a=s.find(n=>n.id===c);return a?o[c]=v({error:this.getErrorMessage(a.errorCode,"folder"),errorCode:a.errorCode},a.errorCode===g.PERMISSION_DENIED&&{accessType:t[c]??i??A}):o[c]={accessRole:r.viewerFolderIds?.includes(D(c))?p.VIEWER:p.EDITOR,accessType:t[c]??i??A},o},{})}buildDocumentPermissions(e,r,s,t,i){return e.reduce((o,c)=>{let a=s.find(n=>n.id===c);return a?o[c]=v({error:this.getErrorMessage(a.errorCode,"document"),errorCode:a.errorCode},a.errorCode===g.PERMISSION_DENIED&&{accessType:t[c]??i??A}):o[c]={accessRole:r.viewerDocumentIds?.includes(_(c))?p.VIEWER:p.EDITOR,accessType:t[c]??i??A},o},{})}buildOrganizationPermission(e,r,s){return s?{error:this.getErrorMessage(s.errorCode,"organization"),errorCode:s.errorCode}:{accessRole:r.viewerOrganizationIds?.includes(e)?p.VIEWER:p.EDITOR}}processTemporaryUserPermissions(e,r){for(let s of r)if(s?.userId)switch(this.ensureUserPermissionStructure(e,s.userId),s.type){case"folder":this.addTemporaryFolderPermission(e,s);break;case"document":this.addTemporaryDocumentPermission(e,s);break;case"organization":this.addTemporaryOrganizationPermission(e,s);break}}ensureUserPermissionStructure(e,r){e[r]||(e[r]={})}addTemporaryFolderPermission(e,r){let{userId:s,resourceId:t,role:i,expiresAt:o}=r;e[s].folders||(e[s].folders={}),e[s].folders[t]={accessRole:i??p.EDITOR,expiresAt:o}}addTemporaryDocumentPermission(e,r){let{userId:s,resourceId:t,role:i,expiresAt:o}=r;e[s].documents||(e[s].documents={}),e[s].documents[t]={accessRole:i??p.EDITOR,expiresAt:o}}addTemporaryOrganizationPermission(e,r){let{userId:s,resourceId:t,role:i,expiresAt:o}=r;e[s].organization||(e[s].organization={}),e[s].organization[t]={accessRole:i??p.EDITOR,expiresAt:o}}hasEditAccess({organizationId:e,folderId:r,documentId:s}){try{let t=!0,i=this.getCurrentUserPermissionsWithServerIds(),o=this.authService.getUser()?.userId??"";return i&&(e&&typeof e=="string"&&i?.[o]?.organization?.[e]&&(i?.[o]?.organization?.[e]?.accessRole===p.VIEWER||i?.[o]?.organization?.[e]?.errorCode===g.PERMISSION_DENIED)&&(t=!1),r&&typeof r=="string"&&i?.[o]?.folders?.[r]&&(i?.[o]?.folders?.[r]?.accessRole===p.VIEWER||i?.[o]?.folders?.[r]?.errorCode===g.PERMISSION_DENIED)&&(t=!1),s&&typeof s=="string"&&i?.[o]?.documents?.[s]&&(i?.[o]?.documents?.[s]?.accessRole===p.VIEWER||i?.[o]?.documents?.[s]?.errorCode===g.PERMISSION_DENIED)&&(t=!1)),t}catch{return!0}}getCurrentUserPermissions$(){return this.currentUserPermissions$.asObservable().pipe(F(V))}getCurrentUserPermissions(){return this.currentUserPermissions$.value}refactorPermissionsWithServerIds(e){try{let r=JSON.parse(JSON.stringify(e??{})),s=this.authService.getUser()?.userId??"";if(r?.[s]){let t=this.docService.getDocumentPaths()?.clientOrganizationId??"";if(r?.[s]?.organization?.[t]){let i=k(t);r[s].organization&&(r[s].organization[i]=r[s].organization[t],delete r[s].organization[t])}r?.[s]?.folders&&(r[s].folders=Object.fromEntries(Object.entries(r?.[s]?.folders??{}).map(([i,o])=>[D(i),o]))),r?.[s]?.documents&&(r[s].documents=Object.fromEntries(Object.entries(r?.[s]?.documents??{}).map(([i,o])=>[_(i),o])))}return r}catch(r){return this.loggingService.catch("Error in UsersPermissionService refactorPermissionsWithServerIds:",r),e}}getCurrentUserPermissionsWithServerIds$(){return this.currentUserPermissions$.asObservable().pipe(W(e=>this.refactorPermissionsWithServerIds(e)),F(V))}getCurrentUserPermissionsWithServerIds(){return this.refactorPermissionsWithServerIds(this.currentUserPermissions$.value)}setCurrentUserPermissions(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setCurrentUserPermissions","color: green;");let r=null;e&&(r=JSON.parse(JSON.stringify(e))),this.currentUserPermissions$.next(r)}catch(r){this.loggingService.catch("Error in UsersPermissionService setCurrentUserPermissions:",r)}}getIsContextEnabled(){return this.loggingService.log("%c[WB] Calling FUNCTION: getIsContextEnabled","color: green;"),this.permissionProvider$.value?.isContextEnabled??!1}setPermissionProvider(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setPermissionProvider","color: green;"),this.clientResolverProdWarned=!1,this.clientResolverNoResolverWarned=!1,this.permissionProvider$.next(e)}catch(r){this.loggingService.catch("Error in UsersPermissionService setPermissionProvider:",r)}}get isRevokeAccessOnDocumentUnsetEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===U.DOCUMENT_UNSET)??!1}get isRevokeAccessOnUserLogoutEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===U.USER_LOGOUT)??!1}get isRevokeOrganizationAccessOnUserLogoutEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===U.USER_LOGOUT&&e.revokeOrganizationAccess)??!1}get isRevokeOrganizationAccessOnDocumentUnsetEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===U.DOCUMENT_UNSET&&e.revokeOrganizationAccess)??!1}getPermissionProviderRetryConfig(){return this.permissionProvider$.value?.retryConfig??{retryCount:0,retryDelay:0}}revokeAccessOnUserLogout(){return m(this,null,function*(){let e=G();try{if(this.isRevokeAccessOnUserLogoutEnabled){let r=[],s=this.authService.getUser()?.userId??"";if((this.getPermissionsCache()??[]).forEach(i=>{i.userId===s&&i.hasAccess&&(i.type===I.ORGANIZATION?this.isRevokeOrganizationAccessOnUserLogoutEnabled&&r.push(O(v({},i),{hasAccess:!1})):r.push(O(v({},i),{hasAccess:!1})))}),r.length>0){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_FORMED,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{requests:r}}),this.setPermissionsCache([]),this.clearRequestKeyedPermissionsCache(),this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_TRIGGERED,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{requests:r}});let i=yield this.revokeAccess({requests:r,userId:this.authService.getUser()?.userId??""});i.success?this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_RESULT,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{result:{data:i,success:!0,statusCode:200}}}):this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{result:{data:i,success:!1,statusCode:500}}})}}}catch(r){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{error:r}}),this.loggingService.catch("Error in UsersPermissionService revokeAccessOnUserLogout:",r)}})}getRevokeKey(e){try{return`${e.userId}_${e.resourceId}_${e.type}_${e.organizationId}`}catch(r){return this.loggingService.catch("Error in UsersPermissionService getRevokeKey:",r),""}}cancelPendingRevokes(e){try{e.forEach(r=>{let s=this.getRevokeKey({userId:r.userId,resourceId:r.resource.id,type:r.resource.type,organizationId:r.resource.organizationId});this.pendingRevokeRequests.has(s)&&this.pendingRevokeRequests.delete(s)}),this.pendingRevokeRequests.size===0&&this.pendingRevokeTimeoutId&&(clearTimeout(this.pendingRevokeTimeoutId),this.pendingRevokeTimeoutId=null)}catch(r){this.loggingService.catch("Error in UsersPermissionService cancelPendingRevokes:",r)}}flushPendingRevokes(){return m(this,null,function*(){let e=this.pendingRevokeUniqueId,r=this.pendingRevokeUserId;try{let s=Array.from(this.pendingRevokeRequests.values());if(this.pendingRevokeRequests.clear(),this.pendingRevokeTimeoutId=null,this.pendingRevokeUniqueId="",this.pendingRevokeUserId="",s.length===0)return;let t=this.getPermissionsCache()??[];s.forEach(c=>{t=t.filter(a=>!(a.resourceId===c.resourceId&&a.type===c.type&&a.organizationId===c.organizationId&&a.userId===c.userId))}),this.setPermissionsCache(t);let i=this.docService.getDocContext(),o=yield this.revokeAccess({requests:s,userId:r,currentContext:i});o.success?this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_RESULT,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{result:{data:o,success:!0,statusCode:200}}}):this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{result:{data:o,success:!1,statusCode:500}}})}catch(s){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{error:s}}),this.loggingService.catch("Error in UsersPermissionService flushPendingRevokes:",s)}})}revokeAccessOnDocumentUnset(t){return m(this,arguments,function*({documentIds:e,folderId:r,context:s}){let i=G();try{if(this.isRevokeAccessOnDocumentUnsetEnabled){let o=[],c=this.docService.getOrganizationConfig()?.clientOrganizationId??"",a=this.authService.getUser()?.userId??"",n=this.getPermissionsCache()??[];e.forEach(d=>{n=this.collectRevokeRequest(n,o,d.clientDocumentId,I.DOCUMENT,c,a)}),r&&(n=this.collectRevokeRequest(n,o,r,I.FOLDER,c,a)),c&&this.isRevokeOrganizationAccessOnDocumentUnsetEnabled&&(n=this.collectRevokeRequest(n,o,c,I.ORGANIZATION,c,a)),s&&this.getIsContextEnabled()&&H({input:s}).forEach(l=>{let u=JSON.stringify(l.access);n=this.collectRevokeRequest(n,o,u,I.CONTEXT,c,a)}),this.setPermissionsCache(n),o.length>0&&(this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_FORMED,timestamp:new Date().getTime(),uniqueId:i,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{requests:o}}),this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_TRIGGERED,timestamp:new Date().getTime(),uniqueId:i,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{requests:o}}),o.forEach(d=>{this.pendingRevokeRequests.set(this.getRevokeKey(d),d)}),this.pendingRevokeUniqueId=i,this.pendingRevokeUserId=a,this.pendingRevokeTimeoutId&&clearTimeout(this.pendingRevokeTimeoutId),this.pendingRevokeTimeoutId=setTimeout(()=>this.flushPendingRevokes(),this.REVOKE_DELAY_MS))}}catch(o){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:i,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{error:o}}),this.loggingService.catch("Error in UsersPermissionService revokeAccessOnDocumentUnset:",o)}})}getAccess(s){return m(this,arguments,function*({requests:e,userId:r}){let t={retryConfig:this.getPermissionProviderRetryConfig()};return this.isClientDevResolverActive()?t.clientResolvedResults=yield this.resolveClientSide(e):this.getPermissionProvider()?.dev&&this.warnNoResolverOnce(),this.sendGetAccessToProxy({requests:e,userId:r,metadata:t})})}sendGetAccessToProxy(t){return m(this,arguments,function*({requests:e,userId:r,metadata:s}){return this.adapterSelectorService?.isPortableBackendActive()?this.sendGetAccessToPortableGateway({requests:e,retryConfig:s?.retryConfig,clientResolvedResults:s?.clientResolvedResults}):this.callHostedGetAccess({type:"getAccess",data:e,metadata:s},r)})}callHostedGetAccess(e,r){return m(this,null,function*(){let s=$(this.functions,x({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield K({methodName:"getAccess",data:e,getSdkProxy:s,userId:r})})}sendGetAccessToPortableGateway(t){return m(this,arguments,function*({requests:e,retryConfig:r,clientResolvedResults:s}){try{let i=this.adapterSelectorService.resolveDbAdapter(),o=[];for(let c of T(e,w)){let a=this.buildPortableGetAccessChunkMetadata(r,this.selectClientResolvedResultsForChunk(s,c)),n=yield i.getAccess(a===void 0?{scope:"org",data:c}:{scope:"org",data:c,metadata:a});if(!n?.ok){let l=n?.code;return this.loggingService.catch("Tier B getAccess denied/failed at the gateway: ",n),{data:[],success:!1,statusCode:this.denialCodeToStatusCode(l)}}let d=n.data?.data??[];o.push(...this.dropUnrequestedEntries(d,c))}return{data:this.skipNotProvidedFolderEntries(o),success:!0,statusCode:200}}catch(i){return this.loggingService.catch("Error in UserPermissionService sendGetAccessToPortableGateway: ",i),{data:[],success:!1,statusCode:500}}})}skipNotProvidedFolderEntries(e){try{this.reportUnrecognizedFolderErrorCodes(e);let r=e.filter(s=>!(s?.type===I.FOLDER&&s?.errorCode==="not_provided"));return r.length!==e.length&&this.loggingService.log(`[WB] Tier B getAccess: ${e.length-r.length} folder answer(s) skipped (errorCode 'not_provided' \u2014 folder subsystem not provisioned on this gateway)`),r}catch(r){return this.loggingService.catch("Error in UserPermissionService skipNotProvidedFolderEntries: ",r),e}}dropUnrequestedEntries(e,r){try{if(!e?.length)return e??[];let s=this.portableGetAccessAskedKeys(r),t=e.filter(i=>s.has(this.portableGetAccessEntryKey(i)));return t.length!==e.length&&this.loggingService.catch("Tier B getAccess returned entries that were not requested \u2014 dropped before the permissions cache: ",e.filter(i=>!s.has(this.portableGetAccessEntryKey(i))),void 0,!0),t}catch(s){return this.loggingService.catch("Error in UserPermissionService dropUnrequestedEntries: ",s),e}}portableGetAccessEntryKey(e){return`${e?.userId}|${e?.resourceId}|${e?.organizationId}|${e?.type}`}portableGetAccessQueryKey(e){return`${e?.userId}|${e?.resource?.id}|${e?.resource?.organizationId}|${e?.resource?.type}`}portableGetAccessAskedKeys(e){return new Set((e??[]).map(r=>this.portableGetAccessQueryKey(r)))}selectClientResolvedResultsForChunk(e,r){try{if(!e?.length)return[];let s=this.portableGetAccessAskedKeys(r),t=e.filter(a=>s.has(this.portableGetAccessEntryKey(a)));if(t.length<=w)return t;let i=new Map,o=!1;for(let a of t){let n=this.portableGetAccessEntryKey(a),d=i.get(n);if(d===void 0){i.set(n,a);continue}let l=d.hasAccess===!0&&a.hasAccess===!0;o=o||d.hasAccess!==a.hasAccess,i.set(n,l===a.hasAccess?a:O(v({},a),{hasAccess:l}))}let c=Array.from(i.values());return this.loggingService.log(`[WB] Tier B getAccess: the resolver answered ${t.length} results for a ${r.length}-question chunk; duplicate keys collapsed to ${c.length} (the last occurrence per key, as the permissions cache keeps it; hasAccess deny-wins) to stay under the gateway's ${w}-entry cap on clientResolvedResults`),o&&!this.clientResolverContradictionWarned&&(this.clientResolverContradictionWarned=!0,console.warn("[Velt] The client-side dev permission resolver answered the same permission question more than once with contradicting hasAccess values. The answers were collapsed to a denial (deny wins) before being relayed to the self-hosted gateway. Fix the resolver to answer each question once.")),c}catch(s){return this.loggingService.catch("Error in UserPermissionService selectClientResolvedResultsForChunk: ",s),[]}}buildPortableGetAccessChunkMetadata(e,r){if(!(e===void 0&&!r?.length))return v(v({},e===void 0?{}:{retryConfig:e}),r?.length?{clientResolvedResults:r}:{})}reportUnrecognizedFolderErrorCodes(e){try{for(let r of e??[]){let s=r?.errorCode;!s||r?.type!==I.FOLDER||s==="not_provided"||this.reportedUnknownFolderErrorCodes.has(s)||(this.reportedUnknownFolderErrorCodes.add(s),console.warn(`Velt [portable backend]: a folder permission entry carried an unrecognised errorCode '${s}'. It is being consumed verbatim (hasAccess is honoured as sent). If your gateway means the folder subsystem is not provisioned, the expected literal is the exact lowercase 'not_provided' \u2014 anything else reads as a REAL denial and will withhold folder-scoped access.`))}}catch(r){this.loggingService.catch("Error in UserPermissionService reportUnrecognizedFolderErrorCodes: ",r)}}denialCodeToStatusCode(e){switch(e){case"unauthenticated":return 401;case"permission-denied":return 403;case"not-found":return 404;case"invalid-argument":return 400;case"failed-precondition":return 412;case"resource-exhausted":return 429;case"unimplemented":return 501;default:return 500}}isClientDevResolverActive(){return!!this.getPermissionProvider()?.dev&&this.isClientDevResolverConfigured()}resolveClientSidePermissions(e){return m(this,null,function*(){if(!this.isClientDevResolverActive())throw new Error("Client-side dev permission resolver is not active");return this.resolveClientSide(e)})}isClientDevResolverConfigured(){let e=this.getPermissionProvider();return e?!!e.endpointConfig?.url?.trim()||typeof e.resolvePermissions=="function":!1}resolveClientSide(e){return m(this,null,function*(){this.warnClientResolverEnabledOnce();let r=this.getPermissionProvider(),s=this.getPermissionProviderRetryConfig(),t=r?.resolveTimeout??6e4,i=yield q(()=>this.withResolverTimeout(()=>this.invokeResolver(e,r),t),"clientPermissionResolver",{retryCount:s?.retryCount??0,retryDelay:s?.retryDelay??0});if(!i||!i.success||i.statusCode!==200)throw new Error(i?.message??"Client permission resolver failed");let o=i.data;if(!Array.isArray(o))throw new Error("Client permission resolver returned a malformed payload");return o})}invokeResolver(e,r){return m(this,null,function*(){let s={data:{requests:e}},t=r.endpointConfig?.url?.trim();if(t)return X(t,r.endpointConfig?.headers,s,!0,r.endpointConfig?.credentials);let i=yield r.resolvePermissions(s);if(Array.isArray(i))return{data:i,success:!0,statusCode:200};let o=i,c=o?.statusCode??(o?.success===!1?500:200),a=o?.success!==!1&&c===200;return{data:Array.isArray(o?.data)?o.data:void 0,success:a,statusCode:a?200:c===200?500:c,message:o?.message}})}withResolverTimeout(e,r){return m(this,null,function*(){if(!r||r<=0)return e();let s,t=new Promise((i,o)=>{s=setTimeout(()=>o(new Error("Client permission resolver timed out")),r)});try{return yield Promise.race([e(),t])}finally{s&&clearTimeout(s)}})}warnClientResolverEnabledOnce(){this.clientResolverProdWarned||(this.clientResolverProdWarned=!0,console.warn("[Velt] Client-side dev permission resolver is enabled (dev: true). Permissions are resolved in the browser for local development only \u2014 DO NOT use this in production. Production API keys ignore browser-resolved results and fall back to the server-side permission provider."))}warnNoResolverOnce(){this.clientResolverNoResolverWarned||(this.clientResolverNoResolverWarned=!0,console.warn("[Velt] setPermissionProvider was called with dev: true but no endpointConfig.url or resolvePermissions callback was provided. Falling back to the server-side permission provider."))}revokeAccess(t){return m(this,arguments,function*({requests:e,userId:r,currentContext:s}){if(this.adapterSelectorService?.isPortableBackendActive())return this.sendRevokeAccessToPortableGateway({requests:e,metadata:this.buildRevokeAccessMetadata(s)});let i=$(this.functions,x({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield K({methodName:"revokeAccess",data:{type:"revokeAccess",data:e,metadata:this.buildRevokeAccessMetadata(s)},getSdkProxy:i,userId:r})})}buildRevokeAccessMetadata(e){return v({retryConfig:this.getPermissionProviderRetryConfig()},e?.access&&{currentContext:e})}sendRevokeAccessToPortableGateway(s){return m(this,arguments,function*({requests:e,metadata:r}){try{let t=this.adapterSelectorService.resolveDbAdapter();for(let i of T(e,w)){let o=yield t.revokeAccess({scope:"org",data:i,metadata:r});if(!o?.ok)return this.loggingService.catch("Tier B revokeAccess denied/failed at the gateway: ",o),{success:!1}}return{success:!0}}catch(t){return this.loggingService.catch("Error in UserPermissionService sendRevokeAccessToPortableGateway: ",t),{success:!1}}})}onResourceAccessRequired(o){return m(this,arguments,function*({requests:e,uniqueId:r,methodName:s,userId:t,fromCache:i=!0}){try{if(!e?.length)return;let c=[],a=this.getPermissionsCache()??[];if(!this.forceRefreshPermissions()&&i&&(e.forEach(n=>{let d=a?.find(l=>l.resourceId===n.resource.id&&l.type===n.resource.type&&l.userId===n.userId&&l.organizationId===n.resource.organizationId);d&&c.push(d)}),c.length>0&&(e=e.filter(n=>!c.find(d=>d.resourceId===n.resource.id&&d.type===n.resource.type&&d.userId===n.userId&&d.organizationId===n.resource.organizationId)))),e.length>0){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:r,methodName:s,source:"internal",payload:{requests:e,fromCache:i,clientResolved:this.isClientDevResolverActive()}});let n=yield this.getAccess({requests:e,userId:this.authService.getUser()?.userId??t??""});return this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.RESOURCE_ACCESS_RESULT,timestamp:new Date().getTime(),uniqueId:r,methodName:s,source:"internal",payload:{result:n,clientResolved:this.isClientDevResolverActive()}}),n?.success&&n?.data?.length&&(this.setPermissionsCache([...a,...n.data]),n.data=[...c,...n.data]),n}else if(c.length>0)return this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.RESOURCE_ACCESS_RESULT_FROM_CACHE,timestamp:new Date().getTime(),methodName:s,source:"internal",uniqueId:r,payload:{results:{data:c,success:!0,statusCode:200}}}),{data:c,success:!0,statusCode:200};return}catch(c){this.loggingService.catch("Error in UsersPermissionService onResourceAccessRequired:",c),this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.RESOURCE_ACCESS_ERROR,timestamp:new Date().getTime(),methodName:s,source:"internal",uniqueId:r,payload:{error:c,requests:e,fromCache:i}});return}})}getPermissionsCache(){return this.forceRefreshPermissions()?[]:this.permissionsCache$.getValue()}forceRefreshPermissions(){return this.getPermissionProvider()?.forceRefresh??!1}setPermissionsCache(e){try{let r=new Map;e.forEach(t=>{let i=`${t.userId}_${t.resourceId}_${t.organizationId}_${t.type}`;r.set(i,t)});let s=JSON.parse(JSON.stringify(Array.from(r.values())));this.permissionsCache$.next(s)}catch(r){this.loggingService.catch("Error in UsersPermissionService setPermissionsCache:",r)}}isPermissionProviderAvailable(){try{return!!this.permissionProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersPermissionService isPermissionProviderAvailable:",e),!1}}getPermissionProvider(){try{return this.permissionProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersPermissionService getPermissionProvider:",e),null}}getPermissionProvider$(){return this.permissionProvider$.asObservable()}};C.PORTABLE_ACTIVATION_WAIT_MS=1e4,C.\u0275fac=function(r){return new(r||C)(R(ie),R(he),R(Y),R(ue),R(ae),R(de),R(te),R(B),R(Q),R(ge))},C.\u0275prov=L({token:C,factory:C.\u0275fac,providedIn:"root"});let M=C;return M})();export{$e as a};
1
+ import{Fa as ge}from"./chunk-3COV4GP2.js";import{B as le,D as ue,E as he,b as oe,m as ne,n as ce,p as ae,s as de}from"./chunk-36PXOB25.js";import{$f as T,$j as se,Dk as te,He as b,Ii as E,Ik as ie,Ji as $,M as F,Pf as p,Qd as B,Qf as g,Uj as ee,Xj as re,_f as j,a as v,ag as _,b as O,ba as L,cg as k,dg as D,di as V,ea as R,ee as S,fa as z,g as m,gi as q,hi as X,kg as J,ki as H,l as N,mi as K,oi as x,qj as Y,rj as Q,sf as U,tf as P,uf as I,v as W,vg as G,wj as Z}from"./chunk-UQB52CCU.js";var A="public",w=100,fe=50,$e=(()=>{let C=class C{constructor(e,r,s,t,i,o,c,a,n,d){this.authService=e,this.docService=r,this.loggingService=s,this.commonDbService=t,this.usersService=i,this.commentUtilsService=o,this.coreActionsService=c,this.functions=a,this.configService=n,this.contactService=d,this.endpointsService=z(Z),this.adapterSelectorService=z(se),this.currentUserPermissions$=new N(null),this.permissionsCache$=new N(null),this.permissionProvider$=new N(null),this.clientResolverProdWarned=!1,this.clientResolverNoResolverWarned=!1,this.requestKeyedPermissionsCache=new Map,this.inFlightPermissionsRequests=new Map,this.permissionsCacheGeneration=0,this.REVOKE_DELAY_MS=3e3,this.pendingRevokeRequests=new Map,this.pendingRevokeTimeoutId=null,this.pendingRevokeUniqueId="",this.pendingRevokeUserId="",this.reportedPortablePermissionFailures=new Set,this.clientResolverContradictionWarned=!1,this.reportedUnknownFolderErrorCodes=new Set;try{this.docService.setUserPermissionService(this),this.authService.setUserPermissionService(this),this.commentUtilsService.setUserPermissionService(this),this.contactService.setUserPermissionService(this)}catch(l){this.loggingService.catch("Error in UserPermissionService constructor:",l)}}ngOnDestroy(){try{this.pendingRevokeTimeoutId&&(clearTimeout(this.pendingRevokeTimeoutId),this.pendingRevokeTimeoutId=null)}catch(e){this.loggingService.catch("Error in UserPermissionService ngOnDestroy:",e)}}collectRevokeRequest(e,r,s,t,i,o){try{return e.find(a=>a.resourceId===s&&a.type===t&&a.organizationId===i&&a.userId===o)?(r.push({userId:o,resourceId:s,organizationId:i,type:t,hasAccess:!1}),e.filter(a=>!(a.resourceId===s&&a.type===t&&a.organizationId===i&&a.userId===o))):e}catch(c){return this.loggingService.catch("Error in UsersPermissionService collectRevokeRequest:",c),e}}hasUserContextAccess({userId:e,accessFields:r}){try{if(!this.getIsContextEnabled()||r.includes(b.DEFAULT_VELT_CONTEXT))return!0;let s=r.filter(i=>!J(i));if(!s.length){if(r.some(c=>c.startsWith(b.VISIBILITY_ORG_PREFIX)))return!0;let o=`${b.VISIBILITY_SELF_PREFIX}${j(e).toString()}`;return r.includes(o)}let t=this.contactService.getUserAccessFieldsByUserId(e);return t?.length?s.every(i=>t.includes(i)):!0}catch(s){return this.loggingService.catch("Error in UserPermissionService hasUserContextAccess:",s),!1}}isMetadataProbeUnanswerable(e){try{return this.adapterSelectorService?.isPortableBackendActive()?!ne(e)&&!ce(e):!1}catch(r){return this.loggingService.catch("Error in UserPermissionService isMetadataProbeUnanswerable: ",r),!1}}organizationDetails(e){return m(this,null,function*(){try{if(this.isMetadataProbeUnanswerable("organizationMetadata"))return{error:!1};let r=yield this.commonDbService?.getData({feature:"organizationMetadata",properties:{organizationId:e,suppressError:!0}});return r&&r?.errorCode?{errorCode:g.PERMISSION_DENIED,error:!0}:r&&!r?.metadata?{errorCode:g.DOES_NOT_EXIST,error:!0}:{error:!1}}catch(r){return this.loggingService.catch("Error in UserPermissionService organizationDetails:",r),{errorCode:g.SOMETHING_WENT_WRONG,error:!0}}})}documentDetails(i){return m(this,arguments,function*({documentId:e,organizationId:r,clientDocumentId:s,clientOrganizationId:t}){try{if(this.isMetadataProbeUnanswerable("documentMetadata")){let d=yield this.docService.readPortableDocumentForProbe?.(e,s,t);return d?.missing?{errorCode:g.DOES_NOT_EXIST,error:!0}:d?.accessType?{error:!1,accessType:d.accessType}:{error:!1}}let o=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:e,organizationId:r,suppressError:!0}});if(o&&o?.errorCode)return{errorCode:g.PERMISSION_DENIED,error:!0};if(o&&!o?.metadata)return{errorCode:g.DOES_NOT_EXIST,error:!0};let c=this.docService.getDocumentMetadata(e)??{};this.docService.setDocumentMetadata(e,v(v({},c),o?.metadata??{}));let a,n=o?.metadata?.veltFolderId;if(n)try{a=(yield this.commonDbService?.getData({feature:"folderMetadata",properties:{folderId:n,organizationId:r}}))?.folderIamConfig?.accessType}catch(d){this.loggingService.catch("Error fetching folder accessType for document:",d)}return a||(a=o?.docIamConfig?.accessType),{error:!1,accessType:a}}catch(o){return this.loggingService.catch("Error in UserPermissionService documentDetails:",o),{errorCode:g.SOMETHING_WENT_WRONG,error:!0}}})}folderDetails(s){return m(this,arguments,function*({folderId:e,organizationId:r}){try{if(this.isMetadataProbeUnanswerable("folderMetadata"))return{error:!1};let t=yield this.commonDbService?.getData({feature:"folderMetadata",properties:{folderId:e,organizationId:r,suppressError:!0}});return t&&t?.errorCode?{errorCode:g.PERMISSION_DENIED,error:!0}:t&&!t?.metadata?{errorCode:g.DOES_NOT_EXIST,error:!0}:{error:!1,accessType:t?.folderIamConfig?.accessType}}catch(t){return this.loggingService.catch("Error in UserPermissionService folderDetails:",t),{errorCode:g.SOMETHING_WENT_WRONG,error:!0}}})}getUserPermissions(e){return m(this,null,function*(){let r=this.permissionsCacheGeneration;try{if(!this.authService.getUser())return this.loggingService.catch("User not set. [source: getUserPermissions]",void 0,void 0,!0),{};let s=this.authService.getUser()?.userId,t=this.extractResourceIds(e);if(!t.clientOrganizationId||!t.organizationId)return this.loggingService.catch("Client organization id or organization id not set during getUserPermissions",void 0,void 0,!0),{};let i=this.adapterSelectorService?.isPortableSession?.()===!0;if(i&&this.adapterSelectorService?.isPortableBackendActive?.()!==!0&&(yield re(C.PORTABLE_ACTIVATION_WAIT_MS),s!==this.authService.getUser()?.userId))return{};let o=yield this.validateResources(t),c;if(i&&this.adapterSelectorService?.isPortableBackendActive?.()===!0){if(c=yield this.fetchPortableUserPermissions(t,o,s??""),s!==this.authService.getUser()?.userId)return{}}else{let[a,n]=yield this.fetchUserPermissionsFromDB(t),d=this.authService.getUser()?.userId;if(s!==d)return{};c=this.buildPermissionsResponse(t,o,a,n)}if(Object.keys(c).length>0){if(!e)this.setCurrentUserPermissions(c);else if(this.permissionsCacheGeneration===r){let a=this.buildPermissionsCacheKey(e);a!==null&&this.requestKeyedPermissionsCache.set(a,JSON.parse(JSON.stringify(c)))}}return c}catch(s){return this.loggingService.catch("Error in UserPermissionService getUserPermissions:",s),{}}})}getUserPermissionsFromCacheOrFetch(e){return m(this,null,function*(){try{if(!e)return yield this.getUserPermissions(e);let r=this.buildPermissionsCacheKey(e);if(r===null)return yield this.getUserPermissions(e);let s=this.permissionsCacheGeneration,t=this.requestKeyedPermissionsCache.get(r);if(t)return JSON.parse(JSON.stringify(t));let i=this.inFlightPermissionsRequests.get(r);if(i){let a=yield i;return this.permissionsCacheGeneration!==s?yield this.getUserPermissions(e):JSON.parse(JSON.stringify(a))}let o=this.getUserPermissions(e);this.inFlightPermissionsRequests.set(r,o),o.finally(()=>{this.inFlightPermissionsRequests.get(r)===o&&this.inFlightPermissionsRequests.delete(r)}).catch(()=>{});let c=yield o;return this.permissionsCacheGeneration!==s?yield this.getUserPermissions(e):JSON.parse(JSON.stringify(c))}catch(r){return this.loggingService.catch("Error in UserPermissionService getUserPermissionsFromCacheOrFetch:",r),{}}})}clearRequestKeyedPermissionsCache(){try{this.requestKeyedPermissionsCache.clear(),this.inFlightPermissionsRequests.clear(),this.permissionsCacheGeneration++}catch(e){this.loggingService.catch("Error in UserPermissionService clearRequestKeyedPermissionsCache:",e)}}invalidateAllPermissionsState(){try{this.reportedPortablePermissionFailures?.clear(),this.requestKeyedPermissionsCache.clear(),this.inFlightPermissionsRequests.clear(),this.permissionsCacheGeneration++}catch(e){this.loggingService.catch("Error in UserPermissionService invalidateAllPermissionsState:",e)}}buildPermissionsCacheKey(e){try{let r={};return Object.keys(e).sort().forEach(s=>{let t=e[s];t!==void 0&&(r[s]=Array.isArray(t)?[...t].sort():t)}),r.__userId=this.authService.getUser()?.userId??null,JSON.stringify(r)}catch(r){return this.loggingService.catch("Error in UserPermissionService buildPermissionsCacheKey:",r),null}}extractResourceIds(e){let r=this.docService.getDocumentPaths(),s=this.docService.getDocumentIds();if(e){let o=e.organizationId??r?.clientOrganizationId;return{folderIds:e.folderIds??[],documentIds:e.documentIds??[],clientOrganizationId:o,organizationId:o?k(o):void 0}}let t=r?.clientOrganizationId;return{folderIds:r?.folderId?[r.folderId]:[],documentIds:s.map(o=>o.clientDocumentId),clientOrganizationId:t,organizationId:t?k(t):void 0}}validateResources(e){return m(this,null,function*(){let{folderIds:r,documentIds:s,organizationId:t,clientOrganizationId:i}=e,o=[],c=[],a=r.length>0||s.length>0;t&&!a&&(o.push(this.organizationDetails(t)),c.push({id:i??"",type:"organization"})),r.forEach(u=>{o.push(this.folderDetails({folderId:D(u),organizationId:t??""})),c.push({id:u,type:"folder"})}),s.forEach(u=>{o.push(this.documentDetails({documentId:_(u),organizationId:t??"",clientDocumentId:u,clientOrganizationId:i})),c.push({id:u,type:"document"})});let[n,d]=yield Promise.all([Promise.allSettled(o),this.getDefaultDocumentAccessType()]),l=this.processValidationResults(n,c);return O(v({},this.suppressResolverGrantedFailures(l,i)),{defaultDocumentAccessType:d})})}suppressResolverGrantedFailures(e,r){try{let s=this.authService.getUser()?.userId;if(!s)return e;let t=this.getPermissionsCache()??[];if(t.length===0)return e;let i=(n,d,l)=>t.some(u=>u?.userId===s&&u?.resourceId===n&&u?.type===d&&(!l||u?.organizationId===l)&&u?.hasAccess===!0),o=e.failedDocumentIds.filter(n=>!(n.errorCode===g.PERMISSION_DENIED&&i(n.id,I.DOCUMENT,r))),c=e.failedFolderIds.filter(n=>!(n.errorCode===g.PERMISSION_DENIED&&i(n.id,I.FOLDER,r))),a=e.failedOrganizationId;return a&&a.errorCode===g.PERMISSION_DENIED&&r&&i(r,I.ORGANIZATION,r)&&(a=void 0),{failedFolderIds:c,failedDocumentIds:o,failedOrganizationId:a,folderAccessTypes:e.folderAccessTypes,documentAccessTypes:e.documentAccessTypes}}catch(s){return this.loggingService.catch("Error in UserPermissionService suppressResolverGrantedFailures:",s),e}}getDefaultDocumentAccessType(){return m(this,null,function*(){try{return(yield this.commonDbService?.getData({feature:"apiKeyMetadata",properties:{}}))?.defaultDocumentAccessType}catch(e){this.loggingService.catch("Error fetching defaultDocumentAccessType:",e);return}})}processValidationResults(e,r){let s=[],t=[],i,o={},c={};for(let a=0;a<e.length;a++){let n=e[a],d=r[a];if(n.status==="rejected"||n.status==="fulfilled"&&n.value.error){let u=n.status==="fulfilled"?n.value.errorCode??g.SOMETHING_WENT_WRONG:g.SOMETHING_WENT_WRONG,h={id:d.id,errorCode:u};switch(d.type){case"organization":if(i=h,u===g.DOES_NOT_EXIST)throw new Error(`Organization with id '${d.id}' does not exist`);break;case"folder":s.push(h);break;case"document":t.push(h);break}}else if(n.status==="fulfilled")switch(d.type){case"folder":n.value.accessType&&(o[d.id]=n.value.accessType);break;case"document":n.value.accessType&&(c[d.id]=n.value.accessType);break}}return{failedFolderIds:s,failedDocumentIds:t,failedOrganizationId:i,folderAccessTypes:o,documentAccessTypes:c}}fetchPortableUserPermissions(e,r,s){return m(this,null,function*(){try{let t=e.clientOrganizationId??"";if(!s||!t)return{};let i=fe,o=T(e.folderIds??[],i),c=T(e.documentIds??[],i),a=Math.max(o.length,c.length,1),n={},d=this.adapterSelectorService.resolveDbAdapter();for(let h=0;h<a;h++){let f={organizationId:t,userIds:[s]};o[h]?.length&&(f.folderIds=o[h]),c[h]?.length&&(f.documentIds=c[h]);let y=yield ee(d,"getUserPermissions",{scope:"org",data:f});if(!y?.ok)return oe("getUserPermissions",y,{logCatch:(me,ve)=>this.loggingService.catch(me,ve,void 0,!0),reported:this.reportedPortablePermissionFailures,isOutcomeUnknown:le}),{};this.reportedPortablePermissionFailures.clear(),this.mergePortablePermissionsMap(n,this.readPortablePermissionsMap(y.data,s))}let l=n[s],u=l?{[s]:l}:{};return l&&(Object.entries(l.documents??{}).forEach(([h,f])=>{if(f&&!f.accessType){let y=r.documentAccessTypes?.[h]??r.defaultDocumentAccessType;y&&(f.accessType=y)}}),Object.entries(l.folders??{}).forEach(([h,f])=>{if(f&&!f.accessType){let y=r.folderAccessTypes?.[h]??r.defaultDocumentAccessType;y&&(f.accessType=y)}})),this.ensureCurrentUserFailuresRecorded(u,t,r.failedFolderIds,r.failedDocumentIds,r.failedOrganizationId,r.folderAccessTypes,r.documentAccessTypes,r.defaultDocumentAccessType),this.processContextPermissions(u),u}catch(t){return this.loggingService.catch("Error in UserPermissionService fetchPortableUserPermissions: ",t),{}}})}readPortablePermissionsMap(e,r){let s=c=>!!c&&typeof c=="object"&&!Array.isArray(c);if(!s(e))return{};let t=new Set(["data","success","statusCode","message"]),i=Object.keys(e);return r!=="data"&&s(e.data)&&i.every(c=>t.has(c))?e.data:e}mergePortablePermissionsMap(e,r){Object.entries(r??{}).forEach(([s,t])=>{if(!t||typeof t!="object")return;let i=e[s]??(e[s]={});t.folders&&(i.folders=v(v({},i.folders??{}),t.folders)),t.documents&&(i.documents=v(v({},i.documents??{}),t.documents)),t.organization&&(i.organization=v(v({},i.organization??{}),t.organization)),t.context&&(i.context=t.context)})}fetchUserPermissionsFromDB(e){return m(this,null,function*(){let{folderIds:r,documentIds:s,organizationId:t}=e,i=[this.authService.getUser()?.userId??""],o=[...r.map(n=>D(n)),...s.map(n=>_(n)),t??""],[c,a]=yield Promise.allSettled([this.usersService.getUsersFromDBWithBatching({userIds:i,organizationId:t}),this.usersService.getTemporaryUsersFromDBWithBatching({userIds:i,organizationId:t,resourceIds:o})]);return[c.status==="fulfilled"?c.value:[],a.status==="fulfilled"?a.value:[]]})}buildPermissionsResponse(e,r,s,t){let{folderIds:i,documentIds:o,clientOrganizationId:c,organizationId:a}=e,{failedFolderIds:n,failedDocumentIds:d,failedOrganizationId:l}=r,u={};return this.processRegularUserPermissions(u,s,i,o,c??"",a??"",n,d,l,r.folderAccessTypes,r.documentAccessTypes,r.defaultDocumentAccessType),this.ensureCurrentUserFailuresRecorded(u,c??"",n,d,l,r.folderAccessTypes,r.documentAccessTypes,r.defaultDocumentAccessType),this.processTemporaryUserPermissions(u,t),this.processContextPermissions(u),u}processContextPermissions(e){try{let r=this.authService.getUser()?.userId;if(r){let s=this.contactService.getUserAccessFieldsByUserId(r);s?.length&&(e[r]||(e[r]={}),e[r].context={accessFields:s})}}catch(r){this.loggingService.catch("Error in UserPermissionService processContextPermissions:",r);return}}processRegularUserPermissions(e,r,s,t,i,o,c,a,n,d,l,u){for(let h of r)for(let f of h)f?.user?.userId&&(e[f.user.userId]=O(v({},s.length&&{folders:this.buildFolderPermissions(s,f,c,d,u)}),{documents:this.buildDocumentPermissions(t,f,a,l,u),organization:{[i]:this.buildOrganizationPermission(o,f,n)}}))}ensureCurrentUserFailuresRecorded(e,r,s,t,i,o,c,a){try{let n=this.authService.getUser()?.userId;if(!n)return;let d=!!i&&!!r,l=(s?.length??0)>0,u=(t?.length??0)>0;if(!d&&!l&&!u)return;if(e[n]||(e[n]={}),d&&(e[n].organization||(e[n].organization={}),e[n].organization[r]||(e[n].organization[r]={error:this.getErrorMessage(i.errorCode,"organization"),errorCode:i.errorCode})),l){e[n].folders||(e[n].folders={});for(let h of s)e[n].folders[h.id]||(e[n].folders[h.id]=v({error:this.getErrorMessage(h.errorCode,"folder"),errorCode:h.errorCode},h.errorCode===g.PERMISSION_DENIED&&{accessType:o[h.id]??a??A}))}if(u){e[n].documents||(e[n].documents={});for(let h of t)e[n].documents[h.id]||(e[n].documents[h.id]=v({error:this.getErrorMessage(h.errorCode,"document"),errorCode:h.errorCode},h.errorCode===g.PERMISSION_DENIED&&{accessType:c[h.id]??a??A}))}}catch(n){this.loggingService.catch("Error in UserPermissionService ensureCurrentUserFailuresRecorded:",n)}}getErrorMessage(e,r){try{switch(this.loggingService.log(`Error in UserPermissionService getErrorMessage: ${e} ${r}`),e){case g.DOES_NOT_EXIST:return`${r} does not exist`;case g.PERMISSION_DENIED:return`User does not have access to ${r}`;case g.SOMETHING_WENT_WRONG:return"Something went wrong";default:return"Something went wrong"}}catch(s){return this.loggingService.catch("Error in UserPermissionService getErrorMessage:",s),"Something went wrong"}}buildFolderPermissions(e,r,s,t,i){return e.reduce((o,c)=>{let a=s.find(n=>n.id===c);return a?o[c]=v({error:this.getErrorMessage(a.errorCode,"folder"),errorCode:a.errorCode},a.errorCode===g.PERMISSION_DENIED&&{accessType:t[c]??i??A}):o[c]={accessRole:r.viewerFolderIds?.includes(D(c))?p.VIEWER:p.EDITOR,accessType:t[c]??i??A},o},{})}buildDocumentPermissions(e,r,s,t,i){return e.reduce((o,c)=>{let a=s.find(n=>n.id===c);return a?o[c]=v({error:this.getErrorMessage(a.errorCode,"document"),errorCode:a.errorCode},a.errorCode===g.PERMISSION_DENIED&&{accessType:t[c]??i??A}):o[c]={accessRole:r.viewerDocumentIds?.includes(_(c))?p.VIEWER:p.EDITOR,accessType:t[c]??i??A},o},{})}buildOrganizationPermission(e,r,s){return s?{error:this.getErrorMessage(s.errorCode,"organization"),errorCode:s.errorCode}:{accessRole:r.viewerOrganizationIds?.includes(e)?p.VIEWER:p.EDITOR}}processTemporaryUserPermissions(e,r){for(let s of r)if(s?.userId)switch(this.ensureUserPermissionStructure(e,s.userId),s.type){case"folder":this.addTemporaryFolderPermission(e,s);break;case"document":this.addTemporaryDocumentPermission(e,s);break;case"organization":this.addTemporaryOrganizationPermission(e,s);break}}ensureUserPermissionStructure(e,r){e[r]||(e[r]={})}addTemporaryFolderPermission(e,r){let{userId:s,resourceId:t,role:i,expiresAt:o}=r;e[s].folders||(e[s].folders={}),e[s].folders[t]={accessRole:i??p.EDITOR,expiresAt:o}}addTemporaryDocumentPermission(e,r){let{userId:s,resourceId:t,role:i,expiresAt:o}=r;e[s].documents||(e[s].documents={}),e[s].documents[t]={accessRole:i??p.EDITOR,expiresAt:o}}addTemporaryOrganizationPermission(e,r){let{userId:s,resourceId:t,role:i,expiresAt:o}=r;e[s].organization||(e[s].organization={}),e[s].organization[t]={accessRole:i??p.EDITOR,expiresAt:o}}hasEditAccess({organizationId:e,folderId:r,documentId:s}){try{let t=!0,i=this.getCurrentUserPermissionsWithServerIds(),o=this.authService.getUser()?.userId??"";return i&&(e&&typeof e=="string"&&i?.[o]?.organization?.[e]&&(i?.[o]?.organization?.[e]?.accessRole===p.VIEWER||i?.[o]?.organization?.[e]?.errorCode===g.PERMISSION_DENIED)&&(t=!1),r&&typeof r=="string"&&i?.[o]?.folders?.[r]&&(i?.[o]?.folders?.[r]?.accessRole===p.VIEWER||i?.[o]?.folders?.[r]?.errorCode===g.PERMISSION_DENIED)&&(t=!1),s&&typeof s=="string"&&i?.[o]?.documents?.[s]&&(i?.[o]?.documents?.[s]?.accessRole===p.VIEWER||i?.[o]?.documents?.[s]?.errorCode===g.PERMISSION_DENIED)&&(t=!1)),t}catch{return!0}}getCurrentUserPermissions$(){return this.currentUserPermissions$.asObservable().pipe(F(V))}getCurrentUserPermissions(){return this.currentUserPermissions$.value}refactorPermissionsWithServerIds(e){try{let r=JSON.parse(JSON.stringify(e??{})),s=this.authService.getUser()?.userId??"";if(r?.[s]){let t=this.docService.getDocumentPaths()?.clientOrganizationId??"";if(r?.[s]?.organization?.[t]){let i=k(t);r[s].organization&&(r[s].organization[i]=r[s].organization[t],delete r[s].organization[t])}r?.[s]?.folders&&(r[s].folders=Object.fromEntries(Object.entries(r?.[s]?.folders??{}).map(([i,o])=>[D(i),o]))),r?.[s]?.documents&&(r[s].documents=Object.fromEntries(Object.entries(r?.[s]?.documents??{}).map(([i,o])=>[_(i),o])))}return r}catch(r){return this.loggingService.catch("Error in UsersPermissionService refactorPermissionsWithServerIds:",r),e}}getCurrentUserPermissionsWithServerIds$(){return this.currentUserPermissions$.asObservable().pipe(W(e=>this.refactorPermissionsWithServerIds(e)),F(V))}getCurrentUserPermissionsWithServerIds(){return this.refactorPermissionsWithServerIds(this.currentUserPermissions$.value)}setCurrentUserPermissions(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setCurrentUserPermissions","color: green;");let r=null;e&&(r=JSON.parse(JSON.stringify(e))),this.currentUserPermissions$.next(r)}catch(r){this.loggingService.catch("Error in UsersPermissionService setCurrentUserPermissions:",r)}}getIsContextEnabled(){return this.loggingService.log("%c[WB] Calling FUNCTION: getIsContextEnabled","color: green;"),this.permissionProvider$.value?.isContextEnabled??!1}setPermissionProvider(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setPermissionProvider","color: green;"),this.clientResolverProdWarned=!1,this.clientResolverNoResolverWarned=!1,this.permissionProvider$.next(e)}catch(r){this.loggingService.catch("Error in UsersPermissionService setPermissionProvider:",r)}}get isRevokeAccessOnDocumentUnsetEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===U.DOCUMENT_UNSET)??!1}get isRevokeAccessOnUserLogoutEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===U.USER_LOGOUT)??!1}get isRevokeOrganizationAccessOnUserLogoutEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===U.USER_LOGOUT&&e.revokeOrganizationAccess)??!1}get isRevokeOrganizationAccessOnDocumentUnsetEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===U.DOCUMENT_UNSET&&e.revokeOrganizationAccess)??!1}getPermissionProviderRetryConfig(){return this.permissionProvider$.value?.retryConfig??{retryCount:0,retryDelay:0}}revokeAccessOnUserLogout(){return m(this,null,function*(){let e=G();try{if(this.isRevokeAccessOnUserLogoutEnabled){let r=[],s=this.authService.getUser()?.userId??"";if((this.getPermissionsCache()??[]).forEach(i=>{i.userId===s&&i.hasAccess&&(i.type===I.ORGANIZATION?this.isRevokeOrganizationAccessOnUserLogoutEnabled&&r.push(O(v({},i),{hasAccess:!1})):r.push(O(v({},i),{hasAccess:!1})))}),r.length>0){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_FORMED,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{requests:r}}),this.setPermissionsCache([]),this.clearRequestKeyedPermissionsCache(),this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_TRIGGERED,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{requests:r}});let i=yield this.revokeAccess({requests:r,userId:this.authService.getUser()?.userId??""});i.success?this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_RESULT,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{result:{data:i,success:!0,statusCode:200}}}):this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{result:{data:i,success:!1,statusCode:500}}})}}}catch(r){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{error:r}}),this.loggingService.catch("Error in UsersPermissionService revokeAccessOnUserLogout:",r)}})}getRevokeKey(e){try{return`${e.userId}_${e.resourceId}_${e.type}_${e.organizationId}`}catch(r){return this.loggingService.catch("Error in UsersPermissionService getRevokeKey:",r),""}}cancelPendingRevokes(e){try{e.forEach(r=>{let s=this.getRevokeKey({userId:r.userId,resourceId:r.resource.id,type:r.resource.type,organizationId:r.resource.organizationId});this.pendingRevokeRequests.has(s)&&this.pendingRevokeRequests.delete(s)}),this.pendingRevokeRequests.size===0&&this.pendingRevokeTimeoutId&&(clearTimeout(this.pendingRevokeTimeoutId),this.pendingRevokeTimeoutId=null)}catch(r){this.loggingService.catch("Error in UsersPermissionService cancelPendingRevokes:",r)}}flushPendingRevokes(){return m(this,null,function*(){let e=this.pendingRevokeUniqueId,r=this.pendingRevokeUserId;try{let s=Array.from(this.pendingRevokeRequests.values());if(this.pendingRevokeRequests.clear(),this.pendingRevokeTimeoutId=null,this.pendingRevokeUniqueId="",this.pendingRevokeUserId="",s.length===0)return;let t=this.getPermissionsCache()??[];s.forEach(c=>{t=t.filter(a=>!(a.resourceId===c.resourceId&&a.type===c.type&&a.organizationId===c.organizationId&&a.userId===c.userId))}),this.setPermissionsCache(t);let i=this.docService.getDocContext(),o=yield this.revokeAccess({requests:s,userId:r,currentContext:i});o.success?this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_RESULT,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{result:{data:o,success:!0,statusCode:200}}}):this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{result:{data:o,success:!1,statusCode:500}}})}catch(s){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{error:s}}),this.loggingService.catch("Error in UsersPermissionService flushPendingRevokes:",s)}})}revokeAccessOnDocumentUnset(t){return m(this,arguments,function*({documentIds:e,folderId:r,context:s}){let i=G();try{if(this.isRevokeAccessOnDocumentUnsetEnabled){let o=[],c=this.docService.getOrganizationConfig()?.clientOrganizationId??"",a=this.authService.getUser()?.userId??"",n=this.getPermissionsCache()??[];e.forEach(d=>{n=this.collectRevokeRequest(n,o,d.clientDocumentId,I.DOCUMENT,c,a)}),r&&(n=this.collectRevokeRequest(n,o,r,I.FOLDER,c,a)),c&&this.isRevokeOrganizationAccessOnDocumentUnsetEnabled&&(n=this.collectRevokeRequest(n,o,c,I.ORGANIZATION,c,a)),s&&this.getIsContextEnabled()&&H({input:s}).forEach(l=>{let u=JSON.stringify(l.access);n=this.collectRevokeRequest(n,o,u,I.CONTEXT,c,a)}),this.setPermissionsCache(n),o.length>0&&(this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_FORMED,timestamp:new Date().getTime(),uniqueId:i,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{requests:o}}),this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_TRIGGERED,timestamp:new Date().getTime(),uniqueId:i,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{requests:o}}),o.forEach(d=>{this.pendingRevokeRequests.set(this.getRevokeKey(d),d)}),this.pendingRevokeUniqueId=i,this.pendingRevokeUserId=a,this.pendingRevokeTimeoutId&&clearTimeout(this.pendingRevokeTimeoutId),this.pendingRevokeTimeoutId=setTimeout(()=>this.flushPendingRevokes(),this.REVOKE_DELAY_MS))}}catch(o){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:i,methodName:P.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{error:o}}),this.loggingService.catch("Error in UsersPermissionService revokeAccessOnDocumentUnset:",o)}})}getAccess(s){return m(this,arguments,function*({requests:e,userId:r}){let t={retryConfig:this.getPermissionProviderRetryConfig()};return this.isClientDevResolverActive()?t.clientResolvedResults=yield this.resolveClientSide(e):this.getPermissionProvider()?.dev&&this.warnNoResolverOnce(),this.sendGetAccessToProxy({requests:e,userId:r,metadata:t})})}sendGetAccessToProxy(t){return m(this,arguments,function*({requests:e,userId:r,metadata:s}){return this.adapterSelectorService?.isPortableBackendActive()?this.sendGetAccessToPortableGateway({requests:e,retryConfig:s?.retryConfig,clientResolvedResults:s?.clientResolvedResults}):this.callHostedGetAccess({type:"getAccess",data:e,metadata:s},r)})}callHostedGetAccess(e,r){return m(this,null,function*(){let s=$(this.functions,x({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield K({methodName:"getAccess",data:e,getSdkProxy:s,userId:r})})}sendGetAccessToPortableGateway(t){return m(this,arguments,function*({requests:e,retryConfig:r,clientResolvedResults:s}){try{let i=this.adapterSelectorService.resolveDbAdapter(),o=[];for(let c of T(e,w)){let a=this.buildPortableGetAccessChunkMetadata(r,this.selectClientResolvedResultsForChunk(s,c)),n=yield i.getAccess(a===void 0?{scope:"org",data:c}:{scope:"org",data:c,metadata:a});if(!n?.ok){let l=n?.code;return this.loggingService.catch("Tier B getAccess denied/failed at the gateway: ",n),{data:[],success:!1,statusCode:this.denialCodeToStatusCode(l)}}let d=n.data?.data??[];o.push(...this.dropUnrequestedEntries(d,c))}return{data:this.skipNotProvidedFolderEntries(o),success:!0,statusCode:200}}catch(i){return this.loggingService.catch("Error in UserPermissionService sendGetAccessToPortableGateway: ",i),{data:[],success:!1,statusCode:500}}})}skipNotProvidedFolderEntries(e){try{this.reportUnrecognizedFolderErrorCodes(e);let r=e.filter(s=>!(s?.type===I.FOLDER&&s?.errorCode==="not_provided"));return r.length!==e.length&&this.loggingService.log(`[WB] Tier B getAccess: ${e.length-r.length} folder answer(s) skipped (errorCode 'not_provided' \u2014 folder subsystem not provisioned on this gateway)`),r}catch(r){return this.loggingService.catch("Error in UserPermissionService skipNotProvidedFolderEntries: ",r),e}}dropUnrequestedEntries(e,r){try{if(!e?.length)return e??[];let s=this.portableGetAccessAskedKeys(r),t=e.filter(i=>s.has(this.portableGetAccessEntryKey(i)));return t.length!==e.length&&this.loggingService.catch("Tier B getAccess returned entries that were not requested \u2014 dropped before the permissions cache: ",e.filter(i=>!s.has(this.portableGetAccessEntryKey(i))),void 0,!0),t}catch(s){return this.loggingService.catch("Error in UserPermissionService dropUnrequestedEntries: ",s),e}}portableGetAccessEntryKey(e){return`${e?.userId}|${e?.resourceId}|${e?.organizationId}|${e?.type}`}portableGetAccessQueryKey(e){return`${e?.userId}|${e?.resource?.id}|${e?.resource?.organizationId}|${e?.resource?.type}`}portableGetAccessAskedKeys(e){return new Set((e??[]).map(r=>this.portableGetAccessQueryKey(r)))}selectClientResolvedResultsForChunk(e,r){try{if(!e?.length)return[];let s=this.portableGetAccessAskedKeys(r),t=e.filter(a=>s.has(this.portableGetAccessEntryKey(a)));if(t.length<=w)return t;let i=new Map,o=!1;for(let a of t){let n=this.portableGetAccessEntryKey(a),d=i.get(n);if(d===void 0){i.set(n,a);continue}let l=d.hasAccess===!0&&a.hasAccess===!0;o=o||d.hasAccess!==a.hasAccess,i.set(n,l===a.hasAccess?a:O(v({},a),{hasAccess:l}))}let c=Array.from(i.values());return this.loggingService.log(`[WB] Tier B getAccess: the resolver answered ${t.length} results for a ${r.length}-question chunk; duplicate keys collapsed to ${c.length} (the last occurrence per key, as the permissions cache keeps it; hasAccess deny-wins) to stay under the gateway's ${w}-entry cap on clientResolvedResults`),o&&!this.clientResolverContradictionWarned&&(this.clientResolverContradictionWarned=!0,console.warn("[Velt] The client-side dev permission resolver answered the same permission question more than once with contradicting hasAccess values. The answers were collapsed to a denial (deny wins) before being relayed to the self-hosted gateway. Fix the resolver to answer each question once.")),c}catch(s){return this.loggingService.catch("Error in UserPermissionService selectClientResolvedResultsForChunk: ",s),[]}}buildPortableGetAccessChunkMetadata(e,r){if(!(e===void 0&&!r?.length))return v(v({},e===void 0?{}:{retryConfig:e}),r?.length?{clientResolvedResults:r}:{})}reportUnrecognizedFolderErrorCodes(e){try{for(let r of e??[]){let s=r?.errorCode;!s||r?.type!==I.FOLDER||s==="not_provided"||this.reportedUnknownFolderErrorCodes.has(s)||(this.reportedUnknownFolderErrorCodes.add(s),console.warn(`Velt [portable backend]: a folder permission entry carried an unrecognised errorCode '${s}'. It is being consumed verbatim (hasAccess is honoured as sent). If your gateway means the folder subsystem is not provisioned, the expected literal is the exact lowercase 'not_provided' \u2014 anything else reads as a REAL denial and will withhold folder-scoped access.`))}}catch(r){this.loggingService.catch("Error in UserPermissionService reportUnrecognizedFolderErrorCodes: ",r)}}denialCodeToStatusCode(e){switch(e){case"unauthenticated":return 401;case"permission-denied":return 403;case"not-found":return 404;case"invalid-argument":return 400;case"failed-precondition":return 412;case"resource-exhausted":return 429;case"unimplemented":return 501;default:return 500}}isClientDevResolverActive(){return!!this.getPermissionProvider()?.dev&&this.isClientDevResolverConfigured()}resolveClientSidePermissions(e){return m(this,null,function*(){if(!this.isClientDevResolverActive())throw new Error("Client-side dev permission resolver is not active");return this.resolveClientSide(e)})}isClientDevResolverConfigured(){let e=this.getPermissionProvider();return e?!!e.endpointConfig?.url?.trim()||typeof e.resolvePermissions=="function":!1}resolveClientSide(e){return m(this,null,function*(){this.warnClientResolverEnabledOnce();let r=this.getPermissionProvider(),s=this.getPermissionProviderRetryConfig(),t=r?.resolveTimeout??6e4,i=yield q(()=>this.withResolverTimeout(()=>this.invokeResolver(e,r),t),"clientPermissionResolver",{retryCount:s?.retryCount??0,retryDelay:s?.retryDelay??0});if(!i||!i.success||i.statusCode!==200)throw new Error(i?.message??"Client permission resolver failed");let o=i.data;if(!Array.isArray(o))throw new Error("Client permission resolver returned a malformed payload");return o})}invokeResolver(e,r){return m(this,null,function*(){let s={data:{requests:e}},t=r.endpointConfig?.url?.trim();if(t)return X(t,r.endpointConfig?.headers,s,!0,r.endpointConfig?.credentials);let i=yield r.resolvePermissions(s);if(Array.isArray(i))return{data:i,success:!0,statusCode:200};let o=i,c=o?.statusCode??(o?.success===!1?500:200),a=o?.success!==!1&&c===200;return{data:Array.isArray(o?.data)?o.data:void 0,success:a,statusCode:a?200:c===200?500:c,message:o?.message}})}withResolverTimeout(e,r){return m(this,null,function*(){if(!r||r<=0)return e();let s,t=new Promise((i,o)=>{s=setTimeout(()=>o(new Error("Client permission resolver timed out")),r)});try{return yield Promise.race([e(),t])}finally{s&&clearTimeout(s)}})}warnClientResolverEnabledOnce(){this.clientResolverProdWarned||(this.clientResolverProdWarned=!0,console.warn("[Velt] Client-side dev permission resolver is enabled (dev: true). Permissions are resolved in the browser for local development only \u2014 DO NOT use this in production. Production API keys ignore browser-resolved results and fall back to the server-side permission provider."))}warnNoResolverOnce(){this.clientResolverNoResolverWarned||(this.clientResolverNoResolverWarned=!0,console.warn("[Velt] setPermissionProvider was called with dev: true but no endpointConfig.url or resolvePermissions callback was provided. Falling back to the server-side permission provider."))}revokeAccess(t){return m(this,arguments,function*({requests:e,userId:r,currentContext:s}){if(this.adapterSelectorService?.isPortableBackendActive())return this.sendRevokeAccessToPortableGateway({requests:e,metadata:this.buildRevokeAccessMetadata(s)});let i=$(this.functions,x({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield K({methodName:"revokeAccess",data:{type:"revokeAccess",data:e,metadata:this.buildRevokeAccessMetadata(s)},getSdkProxy:i,userId:r})})}buildRevokeAccessMetadata(e){return v({retryConfig:this.getPermissionProviderRetryConfig()},e?.access&&{currentContext:e})}sendRevokeAccessToPortableGateway(s){return m(this,arguments,function*({requests:e,metadata:r}){try{let t=this.adapterSelectorService.resolveDbAdapter();for(let i of T(e,w)){let o=yield t.revokeAccess({scope:"org",data:i,metadata:r});if(!o?.ok)return this.loggingService.catch("Tier B revokeAccess denied/failed at the gateway: ",o),{success:!1}}return{success:!0}}catch(t){return this.loggingService.catch("Error in UserPermissionService sendRevokeAccessToPortableGateway: ",t),{success:!1}}})}onResourceAccessRequired(o){return m(this,arguments,function*({requests:e,uniqueId:r,methodName:s,userId:t,fromCache:i=!0}){try{if(!e?.length)return;let c=[],a=this.getPermissionsCache()??[];if(!this.forceRefreshPermissions()&&i&&(e.forEach(n=>{let d=a?.find(l=>l.resourceId===n.resource.id&&l.type===n.resource.type&&l.userId===n.userId&&l.organizationId===n.resource.organizationId);d&&c.push(d)}),c.length>0&&(e=e.filter(n=>!c.find(d=>d.resourceId===n.resource.id&&d.type===n.resource.type&&d.userId===n.userId&&d.organizationId===n.resource.organizationId)))),e.length>0){this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:r,methodName:s,source:"internal",payload:{requests:e,fromCache:i,clientResolved:this.isClientDevResolverActive()}});let n=yield this.getAccess({requests:e,userId:this.authService.getUser()?.userId??t??""});return this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.RESOURCE_ACCESS_RESULT,timestamp:new Date().getTime(),uniqueId:r,methodName:s,source:"internal",payload:{result:n,clientResolved:this.isClientDevResolverActive()}}),n?.success&&n?.data?.length&&(this.setPermissionsCache([...a,...n.data]),n.data=[...c,...n.data]),n}else if(c.length>0)return this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.RESOURCE_ACCESS_RESULT_FROM_CACHE,timestamp:new Date().getTime(),methodName:s,source:"internal",uniqueId:r,payload:{results:{data:c,success:!0,statusCode:200}}}),{data:c,success:!0,statusCode:200};return}catch(c){this.loggingService.catch("Error in UsersPermissionService onResourceAccessRequired:",c),this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:E.Events.PermissionProvider.RESOURCE_ACCESS_ERROR,timestamp:new Date().getTime(),methodName:s,source:"internal",uniqueId:r,payload:{error:c,requests:e,fromCache:i}});return}})}getPermissionsCache(){return this.forceRefreshPermissions()?[]:this.permissionsCache$.getValue()}forceRefreshPermissions(){return this.getPermissionProvider()?.forceRefresh??!1}setPermissionsCache(e){try{let r=new Map;e.forEach(t=>{let i=`${t.userId}_${t.resourceId}_${t.organizationId}_${t.type}`;r.set(i,t)});let s=JSON.parse(JSON.stringify(Array.from(r.values())));this.permissionsCache$.next(s)}catch(r){this.loggingService.catch("Error in UsersPermissionService setPermissionsCache:",r)}}isPermissionProviderAvailable(){try{return!!this.permissionProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersPermissionService isPermissionProviderAvailable:",e),!1}}getPermissionProvider(){try{return this.permissionProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersPermissionService getPermissionProvider:",e),null}}getPermissionProvider$(){return this.permissionProvider$.asObservable()}};C.PORTABLE_ACTIVATION_WAIT_MS=1e4,C.\u0275fac=function(r){return new(r||C)(R(ie),R(he),R(Y),R(ue),R(ae),R(de),R(te),R(B),R(Q),R(ge))},C.\u0275prov=L({token:C,factory:C.\u0275fac,providedIn:"root"});let M=C;return M})();export{$e as a};
@@ -1 +1 @@
1
- import{Ak as n,Ra as s,Za as a,Zc as c}from"./chunk-XUBWZTRK.js";var f=(()=>{let i=class i{constructor(t,r){this.domService=t,this.sanitizer=r}transform(t,r=!0){try{let o=r?this.domService.sanitizeHtml(t):t;return this.sanitizer.bypassSecurityTrustHtml(o)}catch{return t}}};i.\u0275fac=function(r){return new(r||i)(s(n,16),s(c,16))},i.\u0275pipe=a({name:"safeHtml",type:i,pure:!0});let e=i;return e})();export{f as a};
1
+ import{Hk as n,Ra as s,Za as a,Zc as c}from"./chunk-UQB52CCU.js";var f=(()=>{let i=class i{constructor(t,r){this.domService=t,this.sanitizer=r}transform(t,r=!0){try{let o=r?this.domService.sanitizeHtml(t):t;return this.sanitizer.bypassSecurityTrustHtml(o)}catch{return t}}};i.\u0275fac=function(r){return new(r||i)(s(n,16),s(c,16))},i.\u0275pipe=a({name:"safeHtml",type:i,pure:!0});let e=i;return e})();export{f as a};